<?php
header("Content-type: text/html; charset=utf-8");
require('../config.php');
require('../customer_id_decrypt.php'); //导入文件,获取customer_id_en[加密的customer_id]以及customer_id[已解密]
//require('../back_init.php');
$link = mysql_connect(DB_HOST,DB_USER,DB_PWD);
mysql_select_db(DB_NAME) or die('Could not select database');
_mysql_query("SET NAMES UTF8");
/* require('../common/jssdk.php'); */
require('../proxy_info.php');
require('../common/utility.php');
/* $jssdk = new JSSDK($customer_id);
$signPackage = $jssdk->GetSignPackage(); */
/* redis start */
require_once($_SERVER['DOCUMENT_ROOT'].'/mp/function_redis.php');  
/* redis end */
//头文件----start
require('../common/common_from.php');
require('select_skin.php');
//头文件----end
require_once('../function_model/collageActivities.php');
$collageActivities = new collageActivities($customer_id);
/*清除确认订单页面的session 开始*/
	$_SESSION['bug_post_data_'.$user_id] = '';			//清除购物车数据
	$_SESSION['sendtime_id_'.$user_id] = '';			//清除送货时间
	$_SESSION['rtn_sendtime_array_'.$user_id] = '';
	$_SESSION['a_type_'.$user_id] = -1;					//清除选择地址的session
	$_SESSION['diy_area_id_'.$user_id] = '';			//清除自定义区域
	$_SESSION['rtn_diy_area_array_'.$user_id] = '';
	$_SESSION['check_first_extend_'.$user_id] = '';
	$_SESSION['is_virtual_'.$user_id]	= '';
	$_SESSION['is_collage_product_'.$user_id]	= '';
    $_SESSION['is_check_password_'.$user_id] = '';			//清除密码输入记录
	$_SESSION['delivery_time_'.$user_id] = '';			//预配送时间
    $_SESSION['o_shop_id_'.$user_id] = '';          //订货系统门店id
	/*sz郑培强添加用于众筹活动 砍价活动*/
	$_SESSION['form_bargain_sz']='';
	$_SESSION['form_crowdfund_sz']='';
	/*sz郑培强添加用于众筹活动 砍价活动*/
/*清除确认订单页面的session 结束*/
//---------判断身份--------//-----2016-11-28--特权专区身份判断--qiao
$user_level = 0;//0:普通粉丝;1：推广员；2：青铜(代理)；3：白银(渠道)；4：黄金(总代)；5：白金(股东)
$promoter_id = -1;
$promoter_status = -1;
$promoter_is_consume = -1;
if( $user_id > 0 ){
	//查询是否推广员，是否拥有股东身份
	$query = "SELECT id,status,is_consume FROM promoters WHERE isvalid=true AND customer_id=$customer_id AND user_id=$user_id LIMIT 1";
	$result= _mysql_query($query) or die('Query failed:24 ' . mysql_error());
	while( $row = mysql_fetch_object($result) ){
		$promoter_id = $row->id;
		$promoter_status = $row->status;
		$promoter_is_consume = $row->is_consume;
	}
}
if( $promoter_is_consume > 0 && $promoter_status == 1 && $promoter_id > 0 ){	//股东
	$user_level = $promoter_is_consume+1;
}elseif( $promoter_is_consume <= 0 && $promoter_status == 1 && $promoter_id > 0 ){	//普通推广员
	$user_level = 1;
}elseif( $promoter_id < 0 ){	//粉丝
	$user_level = 0;
}
//---------判断身份--------//
//echo $user_level;
//产品ID
$pid = -1;
if(!empty($_GET["pid"])){
	$pid = (int)$configutil->splash_new($_GET["pid"]);
}
if ( empty($pid) || $pid <= 0 )
{
    exit("<script>alert('产品id异常');</script>");
}
$exp_user_id = -1;
if( !empty($_GET['exp_user_id']) ){
	$exp_user_id = $configutil->splash_new($_GET["exp_user_id"]);
}
$o_shop_id = -1; //订货系统门店id
if( !empty($_GET['shop_id']) ){
	$o_shop_id = $configutil->splash_new($_GET["shop_id"]);
}
$o_branch_id = -1;//订货系统子门店id
if( !empty($_GET['branch_id']) ){
	$o_branch_id = $configutil->splash_new($_GET["branch_id"]);
}
// echo "o_shop_id: ".$o_shop_id."<br/>";

//判断是否是货到付款产品start
$payondelivery_sql = "select id from pay_on_delivery_products_t where pid = $pid and isvalid =1 and customer_id =".$customer_id;
$payondelivery_res = _mysql_query($payondelivery_sql) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_object($payondelivery_res))
{
	$payondelivery_id = $row->id;
}
//判断货到付款是否开启
$is_delivery = "select is_pay_on_delivery from weixin_commonshops_extend where isvalid=1 and customer_id=$customer_id";
$delivery    = _mysql_query($is_delivery) or die('Query failed: ' . mysql_error());
while ($row  = mysql_fetch_object($delivery))
{
   $ispay_on = $row->is_pay_on_delivery;
}
//判断是否是货到付款产品end
/*
$live_room_id=0;//商城直播那边传过来的房间id
if(!empty($_GET['live_room_id'])&&is_numeric($_GET['live_room_id'])&&$_GET['live_room_id']>0){
	$live_room_id = $configutil->splash_new($_GET["live_room_id"]);
}
*/
$pro_act_id        = -1;		//产品活动id
$pro_act_type      = -1;		//产品活动类型
$integral_type 	   =  1;		//积分活动类型：1购买产品赠送积分，2积分兑换/换购产品
$is_store_integral =  0;		//是否是门店积分
$integral_now_price = 0;        //积分兑换产品现价
/**		
	产品活动类型（如果是从活动专区进来，必须带上此参数，活动优先级最高，不进行优先级判断）
	$pro_act_type	10~19 拼团（拼团没有整合，自己带另外的参数进来玩，优先级最高，这里的类型暂时没用的）	
	$pro_act_type	20~29 积分	21送积分  22兑换
	$pro_act_type	30~39 限购	
	$pro_act_type	40~49 砍价（砍价用了另外的框架，不使用这个页面，暂时没用）
	$pro_act_type	50~59 众筹（众筹用了另外的框架，不使用这个页面，暂时没用）
**/
if(!empty($_GET['pro_act_type'])&&is_numeric($_GET['pro_act_type'])&&$_GET['pro_act_type']>0){
	$pro_act_type = $configutil->splash_new($_GET["pro_act_type"]);
	if($pro_act_type == 21){
		$integral_type = 1;
	}else if($pro_act_type == 22){
		$integral_type     = 2;
	}
}

$topic_id=0;//商城直播那边传过来的话题id
if(!empty($_GET['topic_id'])&&is_numeric($_GET['topic_id'])&&$_GET['topic_id']>0){
	$topic_id = $configutil->splash_new($_GET["topic_id"]);
}
$resource_id=0;//商城直播那边传过来的资源id
if(!empty($_GET['resource_id'])&&is_numeric($_GET['resource_id'])&&$_GET['resource_id']>0){
	$resource_id = $configutil->splash_new($_GET["resource_id"]);
}
/* 积分产品 */
	//自动查找产品是否是积分活动产品
    require_once($_SERVER['DOCUMENT_ROOT'].'/mshop/web/model/integral.php');
    $model_integral = new model_integral();
	$data['p_id'] 		= $pid;
	$data['cust_id'] 	= $customer_id;
	/*if($o_shop_id != -1 && $o_shop_id > 0){     //如果有门店入口
		$integral_result0  	= $model_integral->check_store_integral_product($data);
	}else{*/
	$data['come_type'] 	= $integral_type;   //如果是入口，就只找相应活动
	//var_dump($data);
	$integral_result0  	= $model_integral->check_product_integral_activity($data);
	$act_type 	= 	$integral_result0['act_type'] ;
	$act_id 	= 	$integral_result0['act_id'] ;
	$pro_act_id = 0;
	$integral_act_type = 0;
	if($act_type >0){
		$pro_act_id = $act_id;
	}
	if($act_type == 0){
		$integral_act_type = 1;		//商城常量积分
	}elseif($act_type == 1){		
		$integral_act_type = 1;		//商城赠送积分	
	}elseif($act_type == 2){
		$integral_act_type = 2;		//兑换积分
	}/*elseif($act_type == 3){
		$integral_act_type = 3;		//门店常量积分
		$is_store_integral = 1;
	}*/
	//echo "<br/>";
	//var_dump($integral_result0);
    $data2['type'] 			= $integral_type;			//类型 1赠送积分 2推荐积分
    $data2['integral_type'] = $is_store_integral;		//是否是门店积分 0不 1是
    $data2['pro_json']		=  array(
                                    array(
                                        'pid' 		=> $pid,
                                        'num' 		=> 1,
                                        'pros_id' 	=> '',
                                        'act_id' 	=> $act_id
                                    )
                                 );

    $data2['pro_json'] = json_encode($data2['pro_json']);     //产品信息 json
    $data2['customer_id']	= $customer_id;		//商家id
    $integral_result = $model_integral->cal_product_integral($data2);
    //var_dump($data);
    //如果兑换活动有误
    if($integral_type == 2 && $integral_result['data'][$pid]['isvalid'] == 0 ){
        $data2['type'] 	 = $integral_type = 1;			//类型 1赠送积分 2兑换积分
        $integral_result = $model_integral->cal_product_integral($data);
    }
    if($integral_type == 2){
        $queryi = "select start_time,end_time from ".WSY_SHOP.".integral_activity where isvalid=1 and act_id=$act_id";
        $resulti    = _mysql_query($queryi) or die('queryi failed: ' . mysql_error());
        while ($rowi  = mysql_fetch_object($resulti))
        {
           $istart_time = $rowi->start_time;
           $iend_time = $rowi->end_time;
        }
    }
//var_dump($integral_result0);
/* 积分产品 */
$is_cashback = 0;//是否开启消费奖励
$query="select is_godefault,is_coupon,is_cashback from weixin_commonshops where isvalid=true and customer_id=".$customer_id;
$is_godefault= 0;
$is_coupon =0;//是否开启优惠券 1：开启 0:关闭
$result = _mysql_query($query) or die('Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
  $is_godefault = $row->is_godefault;
  $is_coupon = $row->is_coupon;
  $is_cashback = $row->is_cashback;//是否开启消费奖励
}
$flag_is_godefault=0;
if(!empty($_GET["flag_is_godefault"])){
	$flag_is_godefault=$configutil->splash_new($_GET["flag_is_godefault"]); //单品页传过来的标识
}
$is_collage_from = 0;
if( !empty($_GET['is_collage_from']) ){
	$is_collage_from = $configutil->splash_new($_GET["is_collage_from"]);
}
if($is_godefault==1&&$flag_is_godefault==0){ //进去单品页

	if(!empty($_GET['pro_act_type']))
	{
		$pro_act_type = $configutil->splash_new($_GET["pro_act_type"]);
		$acturl       = "&pro_act_type=$pro_act_type";
	}

	header("Location: ../common_shop/jiushop/detail_default.php?pid=".$pid."&customer_id=".$customer_id_en."&exp_user_id=".$exp_user_id."&is_collage_from=".$is_collage_from."&integral_type=".$integral_type.$acturl);
	exit();
}
define("InviteUrl",Protocol.$http_host."/weixinpl/common_shop/jiushop/forward.php?type=2&customer_id=");
$linkurl =InviteUrl.$customer_id_en."&pid=".$pid;

// +----------------------------------------------------------------------
// | 默认地址处理
// +----------------------------------------------------------------------
// | @author: Kai <maifakai@jjweb.net>
// +----------------------------------------------------------------------

/**
 * 获取用户信息
 * @author: Kai <maifakai@jjweb.net>
 * @param int $uid
 * @return array | boolean
 */
function get_attusers($uid = null, $customer_id = null){
	$sql = "select * from weixin_users where customer_id=".$customer_id." and id=".$uid;
	$result = _mysql_query($sql) or die('Query failed: ' . mysql_error());
	if (mysql_num_rows($result) > 0) {
		while ($rowi = mysql_fetch_assoc($result)){
			return $rowi;
		}
	}
	return false;
}

/**
 * 获取用户默认收货地址
 * @author: Kai <maifakai@jjweb.net>
 * @param int $user_id
 * @return array | boolean
 */
function get_attusers_addresses($user_id = null){
	$sql = "select * from weixin_commonshop_addresses where user_id=".$user_id." and is_default=1";
	$result = _mysql_query($sql) or die('Query failed: ' . mysql_error());
	if (mysql_num_rows($result) > 0) {
		while ($rowi = mysql_fetch_assoc($result)){
			return $rowi;
		}
	}
	return false;
}

$data_tjr_uid = ''; //推荐人UID
$data_tjr_address = ''; //推荐人默认地址
$data_uid = $_SESSION['user_id_'.$customer_id]; //本人UID
$attusers_addresses = get_attusers_addresses($data_uid);
$data_uid_address = $attusers_addresses ? $attusers_addresses : ''; //本人默认地址


if(isset($_REQUEST['exp_user_id']) && !empty($_REQUEST['exp_user_id'])){
	$tjr = get_attusers($_REQUEST['exp_user_id'], $customer_id);
	$data_tjr_uid = $tjr ? $tjr['id'] : '';
	if(!empty($data_tjr_uid)){
		$attusers_addresses = get_attusers_addresses($data_tjr_uid);
		$data_tjr_address = $attusers_addresses ? $attusers_addresses : '';
	}
}
if (!empty($data_tjr_uid) && !empty($data_tjr_address)) {
	//有推荐人默认地址
	$result = _mysql_query("UPDATE weixin_commonshop_addresses SET is_default=0 WHERE user_id=".$user_id) or die('Query failed: ' . mysql_error());
	$result = _mysql_query("select * from weixin_commonshop_addresses where user_id=".$data_uid." and name='".$data_tjr_address['name']."'"." and phone='".$data_tjr_address['phone']."'"." and address='".$data_tjr_address['address']."'") or die('Query failed: ' . mysql_error());
	if (mysql_num_rows($result) > 0) {
		//已存在推荐人地址
		$result = _mysql_query("UPDATE weixin_commonshop_addresses SET is_default=1 WHERE user_id=".$data_uid." and name='".$data_tjr_address['name']."'"." and phone='".$data_tjr_address['phone']."'"." and address='".$data_tjr_address['address']."'") or die('Query failed: ' . mysql_error());
	}else{
		//不存在推荐人地址
		$sql = "insert into weixin_commonshop_addresses(id,user_id,address,isvalid,name,phone,location_p,location_c,location_a,identity,is_default,identityimgt,identityimgf,is_deal,location_diy) values ('', '".$data_uid."', '".$data_tjr_address['address']."', '".$data_tjr_address['isvalid']."', '".$data_tjr_address['name']."', '".$data_tjr_address['phone']."', '".$data_tjr_address['location_p']."', '".$data_tjr_address['location_c']."', '".$data_tjr_address['location_a']."', '".$data_tjr_address['identity']."', '1', '".$data_tjr_address['identityimgt']."', '".$data_tjr_address['identityimgf']."', '".$data_tjr_address['is_deal']."', '".$data_tjr_address['location_diy']."')";
		$result = _mysql_query($sql) or die('Query failed: ' . mysql_error());
	}
}else{
	//没推荐人默认地址
	if (empty($data_uid_address) && empty($data_tjr_address) && !empty($data_tjr_uid)) {
		header('Location: https://www.huisuda.com.cn/weixinpl/common_shop/jiushop/tzchoice.php');
	}
}

// +----------------------------------------------------------------------
// | 默认地址处理
// +----------------------------------------------------------------------
// | @author: Kai <maifakai@jjweb.net>
// +----------------------------------------------------------------------


//自身推广出去带自己的推广码
$linkurl =$linkurl."&exp_user_id=".passport_encrypt((string)$user_id);
// echo '<script>alert('.$exp_user_id.');</script>';
/* $owner_id 		= -1;
 $customer_id    = 3243;
$pid            = 1568;
$user_id 	 	= 191099 ; */
$new_baseurl = Protocol.$http_host; //新商城图片显示
//初始化--star
$sid                = -1;	//供应商ID
$pro_reward			= 0;	//产品分佣比例
$isvp	      		= 0;	//是否为vp产品
$is_QR              = -1;	//是否 二维码产品 0:否 1:是
$isout              = 0;	//上架下架, 1:下架 0:上架
$p_name             = "";	//产品名
$weight             = 0;	//产品重量
$p_unit             = "";	//单位
$type_id            = 0;	//所以分类id
$issnapup			= 0;	//是否抢购，1：是，0：否
$vp_score      	    = 0;	//单个vp值
$introduce          = "";	//简短介绍
$meu_level          = 0;	//中评数
$bad_level          = 0;	//差评数
$sell_count			= 0;	//销售量
$is_virtual    		=  0;	//是否为虚拟产品 0:非虚拟产品,1:虚拟产品
$good_level         = 0;	//好评数
$freight_id    		= -1;	//运费模板ID
$p_storenum         = 1;	//库存
$is_invoice         = -1;	//是否开启发票
$propertyids        = "";	//属性id
$for_price        	= 0;	//成本价
$cost_price        	= 0;	//供货价
$p_now_price        = 0;	//现价
$description        = "";	//详细介绍
$p_need_score       = 0;	//购买产品需要的积分
$pis_identity        = 1;	//产品是否需要身份证购买开关
$p_orgin_price      = 0;	//原价
$donation_rate      = 0;	//单品捐赠比率
$is_currency		= 0;	//是否购物币产品，0：不是 1：是
$back_currency		= 0;	//购物币返佣金额
$pro_card_level		= 0;	//购买产品需要会员卡开关
$nowprice_title     = "";	//现价的自定义名称
$specifications 	= "";	//产品规格
$default_imgurl     = "";	//封面图片
$show_sell_count	= 0;	//虚拟销售量
$is_free_shipping	= 0;	//是否包邮，1是，0否
$customer_service  	= "";	//售后保障
$pro_card_level_id  = -1;	//购买产品需要会员卡等级
$is_guess_you_like	= 0;	//是否是猜您喜欢开关：0否1是
$define_share_image = '';	//自定义分先图片 产品分享图片
$first_division		= 0;	//一级分佣金额
$buystart_time		= "";	//商品抢购开始时间
$countdown_time		= "";	//商品抢购倒计时(结束时间)
$product_voice		= "";	//商品语音链接
$product_vedio		= "";	//商品视频链接
$shop_card_id		= -1;	//分销会员卡
$brand_supply_name 	= "";	//品牌供应商店铺名
$brand_tel	 		= "";	//品牌供应商店铺电话
$brand_logo 		= "";	//品牌供应商店铺logo
$advisory_flag		= "";	//咨询电话开关
$is_showdiscuss		= "";	//评论开关
$isOpenSales		= "";	//商城产品销量开关
$init_reward		= 0;	//商城分佣比例
$cashback_r			= -1;	//返现金额（产品价格按比例）
$cashback			= -1;	//返现金额（固定金额）
$isvalid			= true;
$issell				= 0;	//是否开启分销
$issell_model		= 0;	//是否开启分销
$tax_type 			= 1;	//1普通产品，2跨境零售，3直邮 ..
$islimit 			= 0;	//是否限购 0否，1是
$limit_num 			= 0;	//限购数量
$is_first_extend 	= 0;	//是否首次推广奖励产品
$privilege_level    = "";	//特权专区等级 0:粉丝；1：推广员；2：青铜(代理)；3：白银(渠道)；4：黄金(总代)；5：白金(股东)
$link_coupons       = -1;   //是否关联优惠券
$delivery_name 		= '配送时间';	//预配送活动名称
$delivery_id 		= -1;	//预配送时间设置id
$delivery_time 		= '';	//配送时间段
$earliest_hour 		= 0;	//最早配送时间所加的小时
$latest_hour 		= 0;	//最晚配送时间所加的小时
$custom_date 		= '';	//自定义日期
$delivery_limit 	= 0;	//自选配送限制，0：早晚时间设置，1：自定义日期
$pre_delivery_time 	= [];	//预配送数据
$now_time_str		= time();
$now_time    		= date("Y-m-d H:i:s",time());
$is_restricted    	= 0;	//是否正在参与限购活动
$query = 'SELECT
			id,
			isvp,
			pro_reward,
			isvalid,
			name,
			is_QR,
			weight,
			type_id,
			cashback,
			cashback_r,
			cost_price,
			for_price,
			vp_score,
			issnapup,
			storenum,
			meu_level,
			bad_level,
			now_price,
			introduce,
			short_introduce_color,
			remark,
			is_invoice,
			is_virtual,
			freight_id,
			unit,
			isout,
			sell_count,
			need_score,
			good_level,
			orgin_price,
			description,
			propertyids,
			is_identity,
			is_supply_id,
			donation_rate,
			is_currency,
			back_currency,
			product_vedio,
			product_voice,
			buystart_time,
			default_imgurl,
			nowprice_title,
			countdown_time,
			specifications,
			show_sell_count,
			customer_service,
			is_free_shipping,
			pro_card_level_id,
			is_guess_you_like,
			define_share_image,
			tax_type,
			islimit,
			limit_num,
			is_first_extend,
			link_package,
			link_package_img,
			privilege_level,
			link_coupons
			FROM weixin_commonshop_products where id=' . $pid;
// $result = _mysql_query($query) or die('Query failed: ' . mysql_error());
//echo $query;
// while ($row = mysql_fetch_object($result)) {
$result = redis_get("product_detail_{$pid}", $query);
foreach ($result as $row) {
	$isvalid			 = $row->isvalid;
	$pro_reward			 = $row->pro_reward;
	$sid                 = $row->is_supply_id;
	$isvp		         = $row->isvp;
	$isout               = $row->isout;
    $for_price			 = $row->for_price;
    $cost_price			 = $row->cost_price;
    $is_QR			     = $row->is_QR;
    $p_name              = $row->name;
	$p_unit              = $row->unit;
	$cashback			 = $row->cashback;
	$cashback_r			 = $row->cashback_r;
	$weight              = $row->weight;
	$meu_level           = $row->meu_level;
    $bad_level           = $row->bad_level;
	$introduce           = $row->introduce;//简短介绍
	$short_introduce_color    = $row->short_introduce_color;//简短介绍颜色
	$product_remark      = $row->remark;//备注
    $p_storenum          = $row->storenum;
	$good_level          = $row->good_level;
	$sell_count          = $row->sell_count;
    $p_need_score        = $row->need_score;
    $p_now_price         = $row->now_price;
    $description         = $row->description;
    $propertyids         = $row->propertyids;
	$p_orgin_price       = $row->orgin_price;
	$default_imgurl      = $row->default_imgurl;
    $show_sell_count     = $row->show_sell_count;
    $define_share_image  = $row->define_share_image;
    $nowprice_title      = $row->nowprice_title;
	$pro_card_level_id   = $row->pro_card_level_id;
	$pis_identity         = $row->is_identity;
	$donation_rate       = $row->donation_rate;
	$is_invoice		     = $row->is_invoice;
	$vp_score	         = $row->vp_score;
	$freight_id			 = $row->freight_id;
	$is_virtual			 = $row->is_virtual;
    $type_id             = $row->type_id;
    $specifications      = $row->specifications;
	$customer_service    = $row->customer_service;
	//$first_division    	 = $row->first_division;
	$is_free_shipping	 = $row->is_free_shipping;
	$is_currency		 = $row->is_currency;
	$back_currency		 = $row->back_currency;
	$issnapup		 	 = $row->issnapup;
	$buystart_time		 = $row->buystart_time;
	$countdown_time		 = $row->countdown_time;
	$product_voice		 = $row->product_voice;
	$product_vedio		 = $row->product_vedio;
	$is_guess_you_like	 = $row->is_guess_you_like;
	$tax_type 			 = $row->tax_type;
	$islimit 			 = $row->islimit;
	$limit_num 			 = $row->limit_num;
	$is_first_extend 	 = $row->is_first_extend;
	$privilege_level     = $row->privilege_level;
	$link_package     	 = $row->link_package;
	$link_package_img    = $row->link_package_img;
	$link_package_img    = substr($link_package_img,6,strlen($link_package_img));
	$link_coupons        = $row->link_coupons;
	switch ($tax_type) {
			case '1':
				$tax_name = "普通产品";
				break;
			case '2':
				$tax_name = "跨境零售";
				break;
			case '3':
				$tax_name = "国内代发";
				break;
			case '4':
				$tax_name = "海外集货";
				break;
			case '5':
				$tax_name = "海外直邮";
				break;

			default:
				# code...
				break;
		}
	/* 查询是否预配送产品 */
	$query_delivery = "SELECT p.delivery_id, a.delivery_name FROM weixin_commonshop_pre_delivery_product_relation p INNER JOIN weixin_commonshop_pre_delivery a ON p.delivery_id=a.id WHERE p.pid=".$pid." AND p.isvalid=TRUE AND p.customer_id=".$customer_id." AND a.isvalid=TRUE";
	$result_delivery = _mysql_query($query_delivery) or die('Query_delivery failed:'.mysql_error());
	while( $row_delivery = mysql_fetch_object($result_delivery) ){
		$delivery_id = $row_delivery -> delivery_id;
		$delivery_name = $row_delivery -> delivery_name;
	}
	if( $delivery_id > 0 ){
		require_once('pre_delivery.class.php');
		$preDeliveryTime = new preDeliveryTime($customer_id);
		$pre_delivery_time = $preDeliveryTime->getDeliveryTime($delivery_id);
	}
	/* 查询是否预配送产品 */
}
//备注json转数组
  $product_remark = json_decode($product_remark);
  $remark_color = $product_remark[0]->color;
  $remarks = $product_remark[0]->concent;
//查询主属性是否有图片
$attr_img_str   = "'0':{'attr':'默认图','img':'".$default_imgurl."'},";
$attr_parent_id = -1;
$attr_img_array = array();
$attr_index     = 0;
$sql_attr_img   = 'select wxcpai.attr_id,wxcp.name,wxcpai.img,wxcp.parent_id from weixin_commonshop_product_attrimg wxcpai inner join weixin_commonshop_pros wxcp on wxcpai.attr_id = wxcp.id where wxcpai.customer_id='.$customer_id.' and wxcpai.pro_id='.$pid.' and wxcpai.status=1';
$result_attr_img = _mysql_query($sql_attr_img) or die('Query failed sql_attr_img: ' . mysql_error());
while ($row_attr_img = mysql_fetch_object($result_attr_img)) {
	$attr_parent_id  = $row_attr_img->parent_id;
	$temp_img        = $row_attr_img->img;
	$temp_attr_id    = $row_attr_img->attr_id;
	$temp_name       = $row_attr_img->name;
	if( !empty($temp_img) && !empty($temp_attr_id) ){ //'0':{'attr':'默认图','img':default_imgurl}
		$attr_index++;
		$attr_img_str .= "'".$attr_index."':{'attr':'".$temp_name."','img':'".$temp_img."'},";
		//$attr_img_str .= $temp_attr_id.'_'.$temp_img.'_'.$temp_name.',';
		$attr_img_array[$temp_attr_id] = array('img'=>$temp_img,'index'=>$attr_index);
	}
}
$attr_img_str = substr($attr_img_str,0,strlen($attr_img_str)-1);
//查询是否开启商城积分 或者 门店积分
$shop_integral_onoff  = 0;			//商城
$store_integral_onoff = 0;			//门店
$integral_setting="SELECT shop_onoff, store_onoff,basic_json,store_json FROM ".WSY_SHOP.".integral_setting WHERE cust_id='{$customer_id}'";
$res_integral_setting= _mysql_query($integral_setting) or die('integral_onoff failed:'.mysql_error());
$shop_int_name  = '商城积分';
$store_int_name = '门店积分';
while($row_inte = mysql_fetch_object($res_integral_setting)){
	$shop_integral_onoff  =$row_inte->shop_onoff;
	$store_integral_onoff =$row_inte->store_onoff;
	$shop_set 	= json_decode($row_inte->basic_json,TRUE);
	$store_set  = json_decode($row_inte->store_json,TRUE);
	$shop_int_name  = !empty($shop_set['integral_name'])?  $shop_set['integral_name']  :'商城积分';
	$store_int_name = !empty($store_set['integral_name'])? $store_set['integral_name'] :'门店积分';
}
/*** 新的限购活动 start ***/
require_once($_SERVER['DOCUMENT_ROOT'].'/mshop/web/model/restricted_purchase.php');
$restricted_purchase   = new model_restricted_purchase();
$restricted_isout      = 0;		//0:待发布 1:根据开始时间与活动时间进行判断，(已发布，进行中，已结束) 2:中止
$restricted_price      = 0.01;	//活动价格
$purchase_times        = -1;	//限购次数 -1为不限
$quantity_purchased    = -1;	//限购数量 -1时则不限
$buy_times             = 0;		//已购买次数
$buy_quantity          = 0;		//已购买总数
$restricted_id         = -1;	//WSY_SHOP.weixin_commonshop_restricted_purchase表id
$restricted_product_id = -1;	//WSY_SHOP.weixin_commonshop_restricted_purchase_products表id
$rp_data['user_id']     = $user_id;
$rp_data['customer_id'] = $customer_id;
$rp_data['product_id']  = $pid;
//备注李庆伟添加
//3d素材
$query_threed = 'SELECT imgurl,3d_link as threed_link  FROM weixin_commonshop_product_imgs where product_id='.$pid.' and isvalid=1';
$result_threed = _mysql_query($query_threed) or die('Query_threed failed: ' . mysql_error());
while ($row = mysql_fetch_object($result_threed)) {
   $imgurl = $row->imgurl;
   $d_link = $row->threed_link;
   $new_imgurl[]['imgurl'] = $row->imgurl;
}
//3d素材标签
$query_tag = 'SELECT is_open,is_show_tag  FROM '.WSY_PROD.'.3d_model_setting where customer_id='.$customer_id;
$result_tag = _mysql_query($query_tag) or die('Query_tag failed: ' . mysql_error());
$is_open_threed =0;
$is_show_tag_threed =0;
//while ($row = mysql_fetch_object($result_tag)) {
//	$is_open_threed = $row->is_open;
//	$is_show_tag_threed = $row->is_show_tag;
//}
//3d素材标签结束 李庆伟添加结束
$imgUrl = $default_imgurl ? $new_baseurl . $default_imgurl : $pp_imgurl; // 分享图标

//vp值  start
$vp_val = 0;
$vp_query = "select my_vpscore from weixin_user_vp where isvalid = true and customer_id = ".$customer_id." and user_id = ".$user_id;
$vp_result= _mysql_query($vp_query) or die('Query failed vp: ' . mysql_error());
while( $vp_row = mysql_fetch_object($vp_result) ){
    $vp_val = $vp_row->my_vpscore;
    if($vp_val==NULL){
        $vp_val = 0;
    }
}

//vp值 end

$restricted_result   = $restricted_purchase->findRestrictedPurchase($rp_data);		//限购活动信息
//var_dump($restricted_result);
if( $restricted_result['errcode']==0 && !empty($restricted_result['data']) ){
	$buystart_time     = $restricted_result['data']['time_start'];
	$countdown_time    = $restricted_result['data']['time_end'];
	$restricted_isout  = $restricted_result['data']['isout'];
	$purchase_times    = $restricted_result['data']['purchase_times'];
	$quantity_purchased= $restricted_result['data']['quantity_purchased'];
	$restricted_price  = $restricted_result['data']['price'];
	$restricted_id     = $restricted_result['data']['restricted_id'];
	$restricted_product_id= $restricted_result['data']['restricted_product_id'];
	if( $restricted_isout == 1 ){
		if( $now_time > $countdown_time ){
			$restricted_isout = 2;
		}
	}
}
if($restricted_isout == 1 && ($now_time >= $buystart_time) && ($now_time <= $countdown_time) ){
	$is_restricted    = 1;		//产品正在参与限购活动
}
if( $restricted_isout == 1 && $is_restricted == 1 ){
	$issnapup         = 0;		//把旧的抢购活动结束掉
	$p_now_price      = $restricted_price;	//现价改为抢购价
	$show_now_price   = $p_now_price;
	$rp_data['restricted_id']  = $restricted_id;
	$purchase_result  = $restricted_purchase->findUserRestrictedPurchase($rp_data);	//用户购买统计
	if( $purchase_result['errcode']==0 && !empty($purchase_result['data']) ){
		$buy_times    = $purchase_result['data']['buy_times'];
		$buy_quantity = $purchase_result['data']['buy_quantity'];
	}
}
/*** 新的限购活动 end ***/
/* 查找全局购物币抵扣比例 */
$query = "select percentage from currency_percentage_t where isvalid=true and type=1 and customer_id=".$customer_id." limit 0,1";
$result = _mysql_query($query) or die('Query failed: ' . mysql_error());
$percentage = 0;//默认0
while ($row = mysql_fetch_object($result)) {
    $percentage = $row->percentage;//全局购物币抵扣比例
}
/* 查找产品购物币抵扣比例 */
$query2 = "select currency_percentage from commonshop_product_discount_t where isvalid=true and pid=".$pid." limit 0,1";
$result2 = _mysql_query($query2) or die('Query failed: ' . mysql_error());
$currency_percentage = -1;//默认全局
while ($row2 = mysql_fetch_object($result2)) {
    $currency_percentage = $row2->currency_percentage;//产品购物币抵扣比例
}
if($currency_percentage<0){
    $currency_percentage = $percentage;
}
$currency_price = $currency_percentage*$p_now_price;
$currency_price = bcadd($currency_price,0,2);//保留两位小数，不四舍五入
//拼团数据 start
$is_collage_product = 0;	//拼团产品标识，1：是，0否
$explain = [];				//团说明
$groupPrice = 0;
$groupStock = 0;
$show_now_price = $p_now_price;
if( $is_collage_from ){
	$condition = array(
		'cgpt.pid' => $pid,
		'cgpt.isvalid' => true,
		'cgpt.status' => 1,
		'cat.status' => 2,
		'cat.isvalid' => true,
		'wcp.isvalid' => true,
        'ae.isvalid' => true,
        'ae.customer_id' => $customer_id,
		'cat.customer_id' => $customer_id
	);
	$filed = " cgpt.activitie_id,cgpt.price,cgpt.success_num,cgpt.stock,cat.start_time,cat.end_time,cat.user_level,cat.number,cat.type,cat.group_size,ae.type_name ";
	$collage_product_info = $collageActivities->get_recommendation_product_system($condition,$filed)['data'][0];
	// var_dump($collage_product_info);
	if( !empty($collage_product_info) ){
		$linkurl .= "&is_collage_from=1";
		$is_collage_product = 1;
		$singlePrice = 0;	//统一单独购买价格
		$groupPrice = $collage_product_info['price'];	//团购价
		$groupStock = $collage_product_info['stock'];	//团购库存
		//$show_now_price = $groupPrice;
		//获取团说明
        $type_str = $collage_product_info['type_name'];
        $type_explain = $collage_product_info['type_name'].'说明';

		$explain = '';
		$get_explain = $collageActivities->getExplain($customer_id)['content'];
		foreach( $get_explain as $k => $v ){
			if( $v['type'] == $collage_product_info['type'] ){
				$explain = $get_explain[$k];
				break;
			}
		}
		// $explain = $get_explain[$collage_product_info['type']-1];
		// var_dump($explain);
		//获取团推荐设置
		$group_set = $collageActivities->getGroupRecommendation($customer_id);
		if( !empty($group_set) and $group_set['is_open'] == 1 ){
			//获取推荐的团
			$group_type = explode('_',$group_set['type']);
			$condition2 = array(
				'cgot.status' =>  1,
                'cat.status' =>  2,
				'cgot.type' =>  $group_type,
				'cgot.customer_id' =>  $customer_id,
				'cgot.isvalid' =>  true,
				'wu.isvalid' =>  true,
				'cgot.endtime' => '( UNIX_TIMESTAMP(cgot.endtime)>='.time().' or UNIX_TIMESTAMP(cat.end_time)>='.time().')',
                'cat.end_time' => ' UNIX_TIMESTAMP(cat.end_time)>='.time()
			);
			if( $group_set['num'] > 0 ){
				$condition2['limit'] = " LIMIT ".$group_set['num'];
			}
			if( $group_set['sort_type'] == 2 ){
				$condition2['cgot.pid'] = $pid;
				$condition2['cgot.activitie_id'] = $collage_product_info['activitie_id'];
			}
			if( $group_set['sort'] == 1 ){
				$condition2['order_by'] = " ORDER BY cgot.createtime ASC ";
			} else {
				$condition2['order_by'] = " ORDER BY cgot.createtime DESC ";
			}
			$filed2 = " cgot.id,cgot.success_num,cgot.join_num,cgot.endtime,cat.end_time,wu.weixin_name,wu.name,wu.weixin_headimgurl,wu.province ";
			$groups = $collageActivities->get_group_recommendation($condition2,$filed2)['data'];
			// var_dump($groups);
		}
	}
}
//拼团数据 end
/*** 产品活动优先级
 *
 *	@当产品要参与某个活动的时候，要把其他活动结束掉
 *	$is_collage_product		//参与拼团 0否 1是
 *	$integral_type		    //参与积分 0否 1是
 *	$restricted_isout		//参与限购 0否 1是
 *
 **/
$is_check_priority = 1 ;	//是否要进行活动优先级判断 0：不要 1：要
$active_countdown = 0;	//开始时间倒数
//如果参与拼团,拼团自己带参数进来玩，优先级最高，只玩拼团，其他活动全部结束掉，并且不执行优先级比较
if( $is_collage_product ){
	$integral_type      = 0;	//结束积分活动
	$restricted_isout   = 0;	//结束限购
	$is_check_priority  = 0;	//活动专区进来，不执行优先级比较
}else{
	//如果pro_act_type大于0，则是从活动专区进来，优先级最高
	switch( $pro_act_type ){
		case 21:
			$restricted_isout  = 0;	//结束限购
			$is_check_priority = 0;	//活动专区进来，不执行优先级比较
		break;
		case 22:
			$restricted_isout   = 0;	//结束限购
			$is_check_priority = 0;	//活动专区进来，不执行优先级比较
		break;
		/*case 23:
			$restricted_isout   = 0;	//结束限购
			$is_check_priority = 0;	//活动专区进来，不执行优先级比较
		break;*/
		case 31:
			$integral_type = 0;	//结束积分活动
			$is_check_priority = 0;	//活动专区进来，不执行优先级比较
			$pro_act_id	= $restricted_id;
		break;
		default:
		break;
	}
}
/***************** 如果活动自己带参数进来玩的，并且要求活动优先级最高写在上面，并且要把其他活动结束掉  ***********************/
$active_arr = array();
//如果参与限购
if( $restricted_isout == 1 ){
	$active_arr['restricted'] = 1;
	$active_arr['second_type'] = 1;
}
//如果参与积分
if( $integral_act_type > 0 ){
	$active_arr['integral']   = 1;
	$active_arr['second_type'] = $integral_act_type;
}
if( $is_check_priority == 1 ){
	require_once($_SERVER['DOCUMENT_ROOT'].'/mshop/web/model/activity_set.php');
	$activity_set = new model_activity_set();
	$active_arr['customer_id'] = $customer_id;
	$result_act = $activity_set->getProductActivity($active_arr);	//方法里面得出当前产品优先参与的活动
	//echo '<br>';
	//var_dump($result_act);
	if($result_act['errcode']==0 && !empty($result_act['data']['activity'])){
		/**
			$pro_act_id		活动编号
			$pro_act_type	10~19 拼团（拼团自己带参数进来玩，优先级最高，这里的类型没用的）
			$pro_act_type	20~29 积分
			$pro_act_type	30~39 限购
			$pro_act_type	40~49 砍价
			$pro_act_type	50~59 众筹
		**/
		$activity_info = $result_act['data']['activity'];	//活动信息

		$active_countdown = $activity_info['count_down'];


		switch($activity_info['activity_type']){
			//拼团
			case 'collage':
				$integral_type      = 0;	//结束积分活动
				$restricted_isout   = 0;	//结束限购
			break;
			//积分
			case 'integral':
				$is_collage_product = 0;	//结束拼团
				$restricted_isout   = 0;	//结束限购
				$pro_act_type = 20 + $integral_act_type ;
			break;
			//限购
			case 'restricted':
				$is_collage_product = 0;	//结束拼团
				$integral_type      = 0;	//结束积分活动
				$pro_act_id			= $restricted_id;
				$pro_act_type		= 31;
			break;
			//砍价
			case 'bargain':

			break;
			//众筹
			case 'crowdfund':

			break;
			default:
			break;
		}
	}
}
$data_ = [''];
/*** 产品活动优先级 ***/
//查询是否续费活动产品 start
$renewal_id = -1;
$renewal_time = 0;
$query_renewal = "SELECT pr.id,pr.renew_time
						FROM promoter_renewal AS pr
						INNER JOIN promoter_renewal_products AS prp ON prp.renewal_id=pr.id
						WHERE pr.isout=0 AND pr.isvalid=true AND pr.customer_id=".$customer_id." AND prp.product_id=".$pid." AND pr.isvalid=true AND prp.isvalid=true ";
$result_renewal = _mysql_query($query_renewal) or die('Query_renewal failed:'.mysql_error());
while( $row_renewal = mysql_fetch_object($result_renewal) ){
	$renewal_id = $row_renewal -> id;
	$renewal_time = $row_renewal -> renew_time;
}
//查询是否续费活动产品 end
//----根据评论表查询评论数
$good_level		= 0;
$query_good_level = "select count(id) as good from weixin_commonshop_product_evaluations where customer_id=".$customer_id." and product_id=".$pid." and status=1 and type=1 and level=1 and isvalid=true";
$result_good_level = _mysql_query($query_good_level) or die("Query_good_level failed:".mysql_error());
while( $row_good_level = mysql_fetch_object($result_good_level) ){
	$good_level = $row_good_level -> good;
}
$meu_level		= 0;
$query_meu_level = "select count(id) as meu from weixin_commonshop_product_evaluations where customer_id=".$customer_id." and product_id=".$pid." and status=1 and type=1 and level=2 and isvalid=true";
$result_meu_level = _mysql_query($query_meu_level) or die("Query_meu_level failed:".mysql_error());
while( $row_meu_level = mysql_fetch_object($result_meu_level) ){
	$meu_level = $row_meu_level -> meu;
}
$bad_level		= 0;
$query_bad_level = "select count(id) as bad from weixin_commonshop_product_evaluations where customer_id=".$customer_id." and product_id=".$pid." and status=1 and type=1 and level=3 and isvalid=true";
$result_bad_level = _mysql_query($query_bad_level) or die("Query_bad_level failed:".mysql_error());
while( $row_bad_level = mysql_fetch_object($result_bad_level) ){
	$bad_level = $row_bad_level -> bad;
}
//----根据评论表查询评论数
//----判断当前身份是否可以购买
$is_allow_buy = 0;//0:不可购买，1：可购买
if( $privilege_level != "" || $privilege_level != NULL ){
	$info = array();
	$info = explode("_", $privilege_level);
	if(in_array($user_level, $info)){
		$is_allow_buy = 1;
	}else{
		$is_allow_buy = 0;
	}
}else{
	$is_allow_buy = 1;
}
//----判断当前身份是否可以购买
//计算属性的库存
$price_id = 0;
$prices_storenum = 0;
$query_storenum = "select id,sum(storenum) as p_storenum from weixin_commonshop_product_prices where product_id=".$pid."";
$result_storenum = _mysql_query($query_storenum) or die("Query_parent failed:".mysql_error());
//echo $query_storenum;
while( $row_storenum = mysql_fetch_object($result_storenum) ){
	$price_id = $row_storenum -> id;
	$prices_storenum = $row_storenum -> p_storenum;
}
if($price_id>0 ){	//当属性价格表存在记录则以价格表库存为准，否则以产品的库存为准
	$p_storenum = $prices_storenum;
}
//查询订货系统门店和子门店库存  2017-11-08 lj
if($o_shop_id>0 || $o_branch_id>0){
	$p_storenum = 0;
	if($o_shop_id>0){
		$query_o_pro = "select sum(opp.store_count-opp.freeze_count) as p_storenum from orderingretail_proxy_product as opp RIGHT JOIN orderingretail_shop as os on os.proxy_id=opp.proxy_id 
		where os.id=".$o_shop_id." and opp.customer_id=".$customer_id." and opp.product_id='".$pid."'";
		$result_o_pro = _mysql_query($query_o_pro) or die('Query failed111: ' . mysql_error());	
		while ($row_o_pro = mysql_fetch_object($result_o_pro)) {
		 	//$proids = $row_o_pro->proids;
		 	$p_storenum = $row_o_pro->p_storenum;
			 //查询该门店所有子门店库存
//			$query_branch_shop = "select id from orderingretail_shop_branch where shop_id='".$o_shop_id."' and customer_id=".$customer_id." and status='open' and isvalid=true";
//			$result_branch_shop = _mysql_query($query_branch_shop);
//				while ($row_branch_shop = mysql_fetch_object($result_branch_shop)) {
//			 	$branch_id = $row_branch_shop->id;
//	     	$query_branch_pro = "select sum(store_count) as p_storenum from orderingretail_shop_branch_pro where branch_id=".$branch_id." and customer_id=".$customer_id." and product_id='".$pid."'";
//				$result_branch_pro = _mysql_query($query_branch_pro);
//				while ($row_branch_pro = mysql_fetch_object($result_branch_pro)) {
//				 	$p_storenum += $row_branch_pro->p_storenum;
//				}
//			}
		}
	}
		//查询子门店库存
	if($o_branch_id>0){
	 $query_branch_pro = "select sum(store_count-freeze_count) as p_storenum  from orderingretail_shop_branch_pro orderingretail_shop where branch_id=".$o_branch_id." and customer_id=".$customer_id." and product_id='".$pid."'";
			 $result_branch_pro = _mysql_query($query_branch_pro);
			 while ($row_branch_pro = mysql_fetch_object($result_branch_pro)) {
			 	$p_storenum = $row_branch_pro->p_storenum;
			 }                	
	}
	if($p_storenum==""){
		$p_storenum = 0;
	}
}
if($pro_act_type==22){
    //积分兑换产品的库存
     $query_integral_stock = "select stock from ".WSY_SHOP.".integral_exchange_product orderingretail_shop where product_id='".$pid."'";
     $result_integral_stock = _mysql_query($query_integral_stock);
     while ($row_integral_stock = mysql_fetch_object($result_integral_stock)) {
        $p_storenum = $row_integral_stock->stock;
     }
    if($p_storenum==""){
        $p_storenum = 0; 
	}
}
/* 检测是否符合首次推广奖励 start */
$check_first_extend = 0;
//查询上级id
$my_parent_id		= -1;
if($user_id>0) {
    $query_parent = "select parent_id,weixin_name from weixin_users where id=".$user_id." and customer_id=".$customer_id." and isvalid=true";
    $result_parent = _mysql_query($query_parent) or die("Query_parent failed:".mysql_error());
    while( $row_parent = mysql_fetch_object($result_parent) ){
        $my_parent_id = $row_parent -> parent_id;
        $weixin_name = $row_parent -> weixin_name;
    }
    //上级是否推广员
    $query_parent_p = "select count(1) as p_is_promoter from promoters where user_id=".$my_parent_id." and status=1 and isvalid=true and customer_id=".$customer_id;
    $p_is_promoter = 0;
    $result_parent_p = _mysql_query($query_parent_p) or die('Query_parent_p failed:'.mysql_error());
    while ( $row_parent_p = mysql_fetch_object($result_parent_p) ){
        $p_is_promoter = $row_parent_p ->p_is_promoter;
    }
    //上级是否已获得该产品的首次推广奖励
    $extend_id = -1;
    $query_extend = "select id from weixin_commonshop_extend_logs where user_id=".$my_parent_id." and p_id=".$pid." and customer_id=".$customer_id." and isvalid=true";
    $result_extend = _mysql_query($query_extend) or die('Query_extend failed:'.mysql_error());
    while( $row_extend = mysql_fetch_object($result_extend) ){
        $extend_id = $row_extend->id;
    }
    //条件：1、从分享页面打开。2、非自己打开分享页面。3、首次推广奖励产品。4、分享人id匹配上级id。5、上级没有获得该产品的首次推广奖励。6、上级是推广员	(在下单页面需要再验证产品是否为首次推广奖励产品)
    if( $exp_user_id > 0 && $exp_user_id != $user_id && $is_first_extend == 1 && $my_parent_id == $exp_user_id && $extend_id < 0 && $p_is_promoter > 0){
        $check_first_extend = 1;
    }
}
/* 检测是否符合首次推广奖励 end */
$introduce 				 = str_replace("\r","",$introduce);
$introduce 				 = str_replace("\n","",$introduce);
$total_evaluate 		 = $good_level+$meu_level+$bad_level;	//评论总数
$buystart_time_str		 = strtotime($buystart_time);
$countdown_time_str		 = strtotime($countdown_time);
/*属性开始*/
$proLst = new ArrayList();
$propertyarr = explode("_",$propertyids);
$pcount = count($propertyarr);
for($i=0;$i<$pcount;$i++){
   $property_id = $propertyarr[$i];
   $proLst->Add($property_id);
}
$default_pids = "";
$proHash = new HashTable();
/*属性结束*/
/*慈善公益*/
$is_charitable        = 0;//慈善开关
$charitable_propotion = 0;//慈善公益最低分配率
$query ="select is_charitable,charitable_propotion from charitable_set_t where isvalid=true and customer_id=".$customer_id;
$result = _mysql_query($query) or die('Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
	$is_charitable        = $row->is_charitable;
	$charitable_propotion = $row->charitable_propotion;
}
$charitable_price = 0;
if( 1 == $is_charitable and $donation_rate < $charitable_propotion ){
	$donation_rate = $charitable_propotion;
}
$charitable_price = $donation_rate * $p_now_price;
$charitable_price = round($charitable_price,2);
/*慈善公益*/
//- 韦工 12:00 2016/9/3 少了issell字段
//$query="select name,init_reward,issell_model,advisory_telephone,advisory_flag,pro_card_level,shop_card_id,isshowdiscount,is_identity,is_showdiscuss,isOpenSales from weixin_commonshops where isvalid=true and customer_id=".$customer_id;
//+ 韦工 12:00 2016/9/3 添加了issell字段
$query="select name,init_reward,issell_model,advisory_telephone,advisory_flag,pro_card_level,shop_card_id,isshowdiscount,is_identity,is_showdiscuss,isOpenSales,issell "
        . "from weixin_commonshops where isvalid=true and customer_id=".$customer_id;
$result = _mysql_query($query) or die('商品归属Query failed2: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
	$issell			 	= $row->issell;//是否开启分销
	$pro_card_level 	= $row->pro_card_level;//购买产品需要会员卡开关
	$shop_card_id   	= $row->shop_card_id;//分销会员卡
	$is_showdiscuss 	= $row->is_showdiscuss;
	$isOpenSales 		= $row->isOpenSales;
	$isshowdiscount 	= $row->isshowdiscount;
	$is_identity 		= $row->is_identity;
	$advisory_flag		= $row->advisory_flag;
	$brand_supply_name 	= $row->name;
	$brand_tel		 	= $row->advisory_telephone;
	$init_reward 		= $row->init_reward;
	$issell_model 		= $row->issell_model;
}
$brand_logo		= "images/dianpu2.png";
$pro_discount = ($p_now_price/$p_orgin_price)*10;	//折扣率
$pro_discount = round($pro_discount ,1);
$total_sales  = $sell_count + $show_sell_count; //虚拟销售量+销售量
if($pro_act_type==22){
    //积分兑换产品的销量
     $query_integral_sales = "select sales_volume from ".WSY_SHOP.".integral_stat_product orderingretail_shop where product_id='".$pid."'";
     $result_integral_sales = _mysql_query($query_integral_sales);
     while ($row_integral_sales = mysql_fetch_object($result_integral_sales)) {
        $total_sales = $row_integral_sales->sales_volume;
     }
    if($total_sales==""){
        $total_sales = 0; 
	}
}
/*返现金额开始*/
require('../common/own_data.php');
$info = new my_data();//own_data.php my_data类
$showAndCashback = $info->showCashback($customer_id,$user_id,$cashback,$cashback_r,$p_now_price);
/*返现金额结束*/
/*是否显示佣金计算器*/
$is_commission_cal = 0;//佣金计算器显示开关
$sql = "select is_commission_cal,barcodes,logo,commission_cal_content,shop_jump_type from weixin_commonshops_extend where isvalid=true and customer_id=".$customer_id;
$result = _mysql_query($sql) or die('Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
	$is_commission_cal 	= $row->is_commission_cal;
	$barcodes 			= $row->barcodes;
	$commonshop_logo 	= $row->logo;
	$commission_cal_content = $row->commission_cal_content;
	$shop_jump_type     = $row->shop_jump_type;
}
if(empty($commission_cal_content)){
    $commission_cal_content = "查看可赚佣金";
}
/*判断产品是否为品牌供应商产品开始*/
$isbrand_supply 	= 0;//1:是品牌供应商，0不是
$pro_num	 		= 0;//品牌供应商店铺产品总数
$collect_num	 	= 0;//品牌供应商收藏总数
$comment_num	 	= 0;//品牌供应商评论总数
$is_admin_closed 	= 0;	//平台是否开启商家店铺
$is_owner_closed 	= 0;	//供应商是否开启商家店铺
if( $sid > 0 ){
	$sql = "select isbrand_supply,shopName,advisory_telephone,advisory_flag,is_admin_closed,is_owner_closed from weixin_commonshop_applysupplys where isvalid=true and user_id=".$sid." limit 0,1";
	$result = _mysql_query($sql) or die('Query failed: ' . mysql_error());
	while ($row = mysql_fetch_object($result)) {
		$isbrand_supply 	= $row->isbrand_supply;
		$brand_supply_name 	= $row->shopName;
		$brand_tel		 	= $row->advisory_telephone;
		$advisory_flag		= $row->advisory_flag;
		$is_admin_closed	= $row->is_admin_closed;
		$is_owner_closed	= $row->is_owner_closed;
	}
	$brand_logo		= "images/dianpu2.png";
	if( $isbrand_supply ){
		$sql = "select brand_logo,brand_supply_name,comment_num,collect_num,pro_num,fan_num from weixin_commonshop_brand_supplys where isvalid=true and brand_status=1 and user_id=".$sid." and customer_id=".$customer_id." limit 0,1";
		$result = _mysql_query($sql) or die('Query failed: ' . mysql_error());
		while ($row = mysql_fetch_object($result)) {
			$brand_logo 		= $row->brand_logo;
			$brand_supply_name 	= $row->brand_supply_name;
			$fan_num 			= $row->fan_num;
		//	$pro_num 			= $row->pro_num;
			$collect_num 		= $row->collect_num;
			$comment_num 		= $row->comment_num;
		}
		$all_query="select count(1) as pcount from weixin_commonshop_products where isvalid=true and isout=false and customer_id=".$customer_id." and is_supply_id=".$sid."";
		$all_result=_mysql_query($all_query) or die ('all_query' .mysql_error());
		while($row=mysql_fetch_object($all_result)){
			$pro_num=$row->pcount;
		}
	}
}else{//非供应商产品展示商城logo
		$brand_logo		= $commonshop_logo;
	}
if( $brand_logo == "" ){
	$brand_logo		= "images/dianpu2.png";
}
/*判断产品是否为品牌供应商产品结束*/
$visit = new CommonUtiliy();
$visit->user_visit_pro($pid,$user_id,$customer_id,1);//产品足迹方法
/* $custom = '购物币';	//自定义购物币名称
$sql_cur = "SELECT custom FROM weixin_commonshop_currency WHERE isvalid = true and customer_id=".$customer_id;
$res_cur = _mysql_query($sql_cur) or die("sql_cur failed:".mysql_error());
if ($row_cur = mysql_fetch_object($res_cur) ){
	$custom = $row_cur->custom;
}
if( empty( $custom ) ){
	$custom = '购物币';
} */
//查询是否开启购物币抵扣
$query = "SELECT isOpen,custom FROM weixin_commonshop_currency WHERE customer_id=".$customer_id;
$result = _mysql_query($query);
$isOpenCurrency = 0;//默认不开启
while( $row = mysql_fetch_object($result) ){
    $isOpenCurrency = $row->isOpen;
    $custom 		= $row->custom;
}
$Plevel = -1;
$is_promoters = -1;
$is_consume 	= -1;
if( $user_id > 0 ){
	$sql = "select commision_level,is_consume from promoters where isvalid=true and user_id=".$user_id." and status=1";
	$result = _mysql_query($sql) or die('Query failed: ' . mysql_error());
	while ($row = mysql_fetch_object($result)) {
		$Plevel 	= $row->commision_level;
		$is_consume = $row->is_consume;
		$is_promoters = 1;
	}
}
/*** 图片是否自动轮播 ***/
$is_product_shuf   = 1;	//是否自动轮播 0否，1是
$is_show_original  = 0;	//是否显示原价 0否，1是
$is_stockOut 	   = 0;	//是否库存不足自动下架
$is_buy_sale_model = 0; //是否是买卖模式，0：默认模式，1：买卖模式
$query_productShuf = "select is_product_shuf,is_show_original,is_stockOut,product_detail_model from weixin_commonshops_extend where isvalid=true and customer_id=".$customer_id;
$result_productShuf = _mysql_query($query_productShuf) or die("Query_productShuf failed:".mysql_error());
while($row_productShuf = mysql_fetch_object($result_productShuf)){
	$is_product_shuf = $row_productShuf->is_product_shuf;
	$is_show_original = $row_productShuf->is_show_original;
	$is_stockOut = $row_productShuf->is_stockOut;
	$is_buy_sale_model = $row_productShuf->product_detail_model;
}
/*** 图片是否自动轮播 ***/
/*优惠券*/
$coupon_id = -1;		//优惠券ID
$coupon_title = '';		//优惠券标题
$NeedMoney = 0;			//优惠券使用限额
$MaxMoney = 0;			//优惠券优惠金额
$CanGetNum = 0;			//每天可领取数量
$user_scene = '';		//优惠券类型
$MoneyType = '';		//领取金额类型
$Days = '';				//截止使用天数
$DaysType = '';			//截止时间类型 0:截止天数,1:截止日期
if($link_coupons!=-1){
	$query_coupon = "select id,title,NeedMoney,MaxMoney,CanGetNum,Days,DaysType,user_scene,MoneyType,class_type,startline,connected_id from weixin_commonshop_coupons where isvalid=true and is_open=true and customer_id=".$customer_id." and (DaysType=0 or (DaysType=1 and Days>='".date("Y-m-d H:i:s",time())."')) and id in (".$link_coupons.") order by connected_id desc, createtime desc";
	$result_coupon = _mysql_query($query_coupon) or die("query_coupon failed:".mysql_error());
	while($row_coupon = mysql_fetch_object($result_coupon)){
		$coupon_array[] = $row_coupon;
	}
    $nowtime = date('Y/m/d',time());                //优惠劵开始时间
    foreach($coupon_array as $key =>$values){
        $coupon_id      = $values->id;
        $coupon_title   = $values->title;
        $NeedMoney      = $values->NeedMoney;
        $MaxMoney       = $values->MaxMoney;        //这里作为单品优惠劵的固定优惠金额
        $CanGetNum      = $values->CanGetNum;
        $MoneyType      = $values->MoneyType;
        $user_scene     = $values->user_scene;
        $Days           = $values->Days;
        $DaysType       = $values->DaysType;        //截止时间类型 0:截止天数,1:截止日期
        $class_type     = $values->class_type;
        $startline      = $values->startline;       //使用开始时间
        $connected_id   = $values->connected_id;    //单品代金卷就是关联产品ID；商铺代金卷就是关联供应商ID
        $coupon_isvalid = true;                     //是否有效
        //当使用开始时间比现在时间要晚，则使用设置的开始时间
        if(strtotime($startline) > time()){
            $nowtime =  date('Y/m/d',strtotime($startline));
        }
        $endtime = '';                          //优惠劵结束时间
        if($DaysType == 1){
            $endtime = $Days;
        }else{
            $endtime = date('Y/m/d',strtotime("+".$Days." day"));
        }
        if($user_scene==1 && !empty($connected_id) ){
            $cou_product_name = array();
            $cou_product_sql  = 'select name from weixin_commonshop_products where id in ('.$connected_id.') and isvalid = 1 ';
            $result_cou_product=_mysql_query($cou_product_sql);
            while ($row_cou = mysql_fetch_object($result_cou_product)) {
                $cou_product_name[] = $row_cou->name;
            }
            if(empty($cou_product_name)){       //查询该产品失败
                $coupon_isvalid = false;
            }
			$cou_product_name = implode(",",$cou_product_name);
            $remark = "仅限购买商品【".$cou_product_name."】使用";
        }elseif( empty($connected_id) ){
            $coupon_isvalid = false;
        }else{
            $remark = "仅限购买平台商品使用";
        }
        // var_dump($is_collage_from == 1 ,$is_collage_from == 0 ,$class_type,$coupon_isvalid);
        if( ($is_collage_from == 1 || ($is_collage_from == 0))&&$coupon_isvalid == true ){
            $result_coupon_num++;
        }
    }
	// $result_coupon_num = count($coupon_array);
}
//微商城id
$sql = "SELECT id FROM weixin_commonshops WHERE isvalid=true AND customer_id=".$customer_id." LIMIT 1";
$res = _mysql_query($sql) or die('Query failed34: ' . mysql_error());
while( $row = mysql_fetch_object($res) ){
	$shop_id = $row->id;    //微商城唯一标识
}
//商城订单提示开关
$query = "select is_openOrderMessage from weixin_commonshops_extend  where isvalid=true and customer_id=".$customer_id." and shop_id=".$shop_id;
$result = _mysql_query($query) or die('tc_erweima_W116 Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
	$is_openOrderMessage = $row->is_openOrderMessage;
}
/*优惠券*/
// 获取当天当前用户当前商品购买数量
$date = date('Y-m-d');
if($user_id >0){
    $sql = "SELECT count(rcount) from weixin_commonshop_orders where createtime like '%{$date}%' and customer_id='{$customer_id}' and isvalid=true and pid='{$pid}' and user_id='{$user_id}' and status <> '-1' ";
    $result = _mysql_query($sql) or die(mysql_error());
    if($result){
        $arr = mysql_fetch_row($result);
        $count_commodity = $arr[0];
    }
}
//用户积分
$sql = "SELECT integral,store_integral FROM moneybag_t WHERE customer_id=".$customer_id." AND user_id=".$user_id." AND isvalid=TRUE";
$res = _mysql_query($sql) or die('Query failed34: ' . mysql_error());
while( $row = mysql_fetch_object($res) ){
	$user_integral = $row->integral;
	$user_store_integral = $row->store_integral;
}
/*** 小能客服系统 ***/
$xiaoneng_id = $sid;
require('supply_chat.php');	//供应商客服方法
/*** 小能客服系统 ***/


/*** 获取购买记录
 *	
 *	author:Code048
 *	@获取购买记录
 *	param $pid		//产品购买记录
 *	return array
 **/
 
 function GetProductRecode($pid=-1)
 {
	 $i = 0;
	 $result['code'] = 'success';
	 $result['msg'] = '查询成功';	 
	 if($pid == -1)
	 {
		 $result['code'] = 'error';
		 $result['msg'] = '参数传递错误';
		 return $result; 
	 }
	 
	 $query = "SELECT w.id,w.weixin_name,w.weixin_headimgurl,o.pid,o.rcount,o.paytime FROM weixin_users AS w LEFT JOIN weixin_commonshop_orders AS o ON w.id=o.user_id WHERE o.customer_id = 41 AND (o.status = 1 OR o.status = 0) AND o.paystatus = 1 AND o.isvalid = 1 AND o.pid = ".$pid;
	 $search_result = _mysql_query($query) or die('Query failed1309: ' . mysql_error());
	 while($row = mysql_fetch_object($search_result))
	 {
		if(strlen(strip_tags($row->weixin_name)) >= 12)
		{
			$result['data'][$i]['weixin_name'] = substr(strip_tags($row->weixin_name),0,12).'...';
		}
		else
		{
			$result['data'][$i]['weixin_name'] = strip_tags($row->weixin_name);
		}
		
		$result['data'][$i]['weixin_headimgurl'] = $row->weixin_headimgurl;
		$result['data'][$i]['rcount'] = $row->rcount;
		$result['data'][$i]['paytime'] = substr($row->paytime,5,strlen($row->paytime));
		$i++;
	 }
	 
	 if(empty($result['data']))
	 {
		 $result['code'] ='success';
		 $result['msg'] = '没有购买记录';
		 return $result;
	 }
	 
	 return $result; 
	 
 }
 
 /*** 获取购买人数、销售总量
 *	
 *	author:Code048
 *	@获取购买人数、销售总量
 *	paramm $pid		//产品购买记录
 *	return array
 *
 **/
 
 function GetProductStat($pid = -1)
 {
	 
	 $result['code'] = 'success';
	 $result['msg'] = '查询成功';	
	 
	 if($pid == -1)
	 {
		 $result['code'] = 'error';
		 $result['msg'] = '参数传递错误';
		 return $result; 
	 }

	 $query = "SELECT count(*) as people_count,sum(rcount) as product_count FROM weixin_users AS w LEFT JOIN weixin_commonshop_orders AS o ON w.id=o.user_id WHERE o.customer_id = 41 AND (o.status = 1 OR o.status = 0) AND o.paystatus = 1 AND o.isvalid = 1 AND o.pid = ".$pid;
	 
	 $search_result = _mysql_query($query) or die('Query failed1360: ' . mysql_error());
	 
	 while($row = mysql_fetch_object($search_result))
	 {
		 $result['data']['people_count'] = $row->people_count;
		 $result['data']['product_count'] = $row->product_count;
	 }
	 
	 if(empty($result['data']))
	 {
		 $result['code'] ='success';
		 $result['msg'] = '没有购买记录';
		 return $result;
	 }	 
	 
	 return $result; 
 }
?>

<!DOCTYPE html>
<html>
<head>
    <title><?php echo $p_name;?></title>
    <!-- 模板 -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta content="no" name="apple-touch-fullscreen">
    <meta name="MobileOptimized" content="320"/>
    <meta name="format-detection" content="telephone=no">
    <meta name=apple-mobile-web-app-capable content=yes>
    <meta name=apple-mobile-web-app-status-bar-style content=black>
    <meta http-equiv="pragma" content="nocache">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">

    <link type="text/css" rel="stylesheet" href="./assets/css/amazeui.min.css" />
	<script type="text/javascript" src="./assets/js/jquery.min.js"></script>
	<?php if($is_openOrderMessage == 1){ ?>
		<script type="text/javascript" src="./js/order_message.js"></script>
	<?php } ?>
    <!-- 模板 -->
    <!-- 页联系style-->
    <link type="text/css" rel="stylesheet" href="./css/goods/global.css" />
    <link type="text/css" rel="stylesheet" href="./css/goods/product_detail.css" />
	<link type="text/css" rel="stylesheet" href="css/order_css/global.css" />
	<link type="text/css" rel="stylesheet" href="./css/css_<?php echo $skin ?>.css" />
	<link type="text/css" rel="stylesheet" href="./css/product_coupon.css" />
	<link href="./css/goods/mobiscroll/mobiscroll.custom-2.17.1.min.css" rel="stylesheet" type="text/css">
	<!-- 属性图预览 -->
	<link type="text/css" rel="stylesheet" href="./css/ImgPreview.css" />
	<link type="text/css" rel="stylesheet" href="./css/swiper.min.css" />
    <!-- 页联系style-->
    <style type="text/css">
		.hide{display:none;}
    	 /*//ld 点击效果*/
        .button{
        	-webkit-transition-duration: 0.4s; /* Safari */
        	transition-duration: 0.4s;
        }
		#button4.item2-panel-button{
			font-size: 14px;
			height: 40px;
			width: 90%;
			text-align: center;
			background-color: #736b6b;
			padding: 0px;
			border-color: #736b6b;
		}
		#button3.item2-panel-button {
			font-size: 14px;
			height: 40px;
			width: 90%;
			text-align: center;
			background-color: #736b6b;
			padding: 0px;
			border-color: #736b6b;
		}
        .buttonclick:hover{
        	box-shadow:  0 0 5px 0 rgba(0,0,0,0.24);
        }
        .am-shui{height: 18px; background: #fff;border:1px solid #ff7109; color: #ff7109;border-radius: 2px;font-size: 13px;padding: 0;}
	   .test5 {
		display: inline-block;
	    height:0;
	    width:20px;
	    color:#fff;
	    line-height: 0;
	    border-color:#ff7109 #fff transparent transparent;
	    border-style:solid solid dashed dashed;
	    border-width:16px 4px 0 0 ;
		}
      .test5 span{display: block;margin-top: -7px;color: #fff;font-weight: bold;}
	  .bi{
		background:#F98C3E;
		margin-right: 4px;
	  }
	  .sanjiao{display:block;width:0;height:0;border-width:0 5px 5px;border-style:solid;border-color:transparent #fd7c24 transparent transparent ;position:absolute;top:0px;left:-10px;}
	  .jianshu{display: inline-block;background: #fd7c24;color: #fff;font-size: 12px; letter-spacing: 1px;border-radius: 0 2px 2px 0;position: relative;margin-left: 1%;padding-left: 3px;}
	  .coupon_img{
		    width: 50px;
			margin-bottom: 6px;
	  }
	.shangpin-addprice .span {
		line-height: 0px; /*这里不要再设置其他值了。我改过三万遍了。*/
	}
	.det{width: 100%;padding: 10px 2.5%;background-color: #fff;border-top: 1px solid #d1d1d1;border-bottom: 1px solid #d1d1d1;font-size: 15px;position: relative;}
	.det img{max-width: 100%;}
	.det .exp{font-size: 17px;color: #2a2a2a;}
	.det .expNum{color: #fe842f;}
	.det .expMore{color: #888888;float: right;margin-top: 2px;margin-right: 5px;}
	.det .icon{width: 20px;height: 20px; background-color: #cccccc;color: #fff;border-radius: 50%;transform: rotate(180deg);-webkit-transform: rotate(180deg);text-align: center;display: inline-block;margin-left: 10px;}
	.det .icon span{line-height: 20px;height: 20px;}
	.det .detBtn{float: right;margin-top: 3px;width: 20px;}
	.det .detBtn2{float: right;margin-top: 3px;height: 20px;}
	.det .detBottom{color: #666666;width: 100%;margin-top: 15px;font-size: 0;}
	.detBottom .time{margin-bottom: 10px;font-size: 12px;}
	.detBottom .detCell{/*width: 25%;text-align: center;*/position: relative;display: inline-block;font-size: 8px;}
	.detCell .num{background-color: #e6e6e6;color: #666666;width: 25px;height: 25px;line-height: 25px; text-align: center;margin: auto;border-radius: 50%;margin-bottom: 5px;}
	.detCell .txtExp{text-align:left;padding: 5px 0;background-color: #f5f5f5;width: 90%;margin: auto;margin-top: 5px;}
	.detCell .img{position: absolute;top: 10px;right: -10px;width: 30px;}
	.collageTag{
		border-color:#FC8B19!important;
		color:#FC8B19!important;margin-right:2px;
	}
	.detCell3{/*background-color: #f7f7f7;*/margin-top:15px;padding: 10px 5px;}
	.detCell3 .headImg2{width: 60px;height: 60px;border-radius: 50%;display: inline-block;vertical-align: middle;}
	.detCell3 .box1{display: inline-block;vertical-align: middle;margin-left: 5px;width: 49%;color: #2a2a2a;font-size: 14px;}
	.detCell3 .box2{display: inline-block;vertical-align: middle;color: #fff;float: right;}
	.box1 p{line-height: 22px;margin: 0;}
	.box1 .line1{font-size: 17px;width: 100%;overflow: hidden;text-overflow: ellipsis; white-space: nowrap;}
	.box1 .line2{color: #707070;}
	.box1 .line3 span{color: #ff8430;margin-left: 5px;}
	.box2 p{padding: 3px 12px;margin: 0;}
	.box2 .top{background-color: #666666;border-top-left-radius: 5px;border-top-right-radius: 5px;}
	.box2 .bottom{background-color: #fe842f;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;color: #fff;}
	.box2 .bottom img{height: 15px;position: relative;top: -2px;left: 5px;}
	#singleBuy,#collageBuy{width: 47%;border: none;}
	#singleBuy{opacity: 0.7;}
	#singleBuy span,#collageBuy span{display: block;font-size: 14px;color: #fff;}
	#xufei{font-size: 1.2rem;color: #5f666b;margin-left: 5px;}
	.sellcontent{
	width: 100%;
    background-color: #ffffff;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
    padding: 10px 24px;
    box-sizing: border-box;
}
.hide{display:none;}
.count{float: left;}
.countDet{color: #cc4d47;font-size: 13px;vertical-align: middle;float: left;line-height: 25px;}
.countld{width: 10px;float: left;margin-right: 2px;margin-top: 4px;}
.am-modal{top: 10%}
.am-modal-dialog img {
    width: 100%;
    height: 100%;
    border-radius: 5px;
}
.big_pro_name span {
	line-height: 33px;
}
.wx_loading_icon{top:200%;}
.buttom-none{border-bottom:0;}
.shangpin-neardate{background-color:#fff;padding:0 3px 10px 3px;box-sizing:border-box;border-bottom:solid 1px #eee;position:relative;width:100%;}
.shangpin-neardate p{margin:0;}
.shangpin-neardate ul{font-size:0;vertical-align:middle;margin:0;position:relative;margin-right:40px;}
.shangpin-neardate ul li{display:inline-block;width:25%;box-sizing:border-box;padding:0 5px;text-align:center;}
.shangpin-neardate ul li.active a{background-color:#e5d1b1;border-color:#cdb99b;}
.shangpin-neardate ul li a{display:block;border:solid 1px #d1d1d1;border-radius:2px;padding:5px;outline:none;}
.shangpin-neardate .time{font-size:1.2rem;color:#333;}
.shangpin-neardate .price{font-size:1.2rem;color:#333;}
.shangpin-neardate .allDate{width:40px;font-size:1.1rem;color:#fd7c24;text-align:center;position:absolute;right:3px;top:0;height:100%;vertical-align:middle;display:inline-block;padding:5px 0;}
.getmovetime{position:absolute;height:100%;top:0;z-index:5;opacity:0;}
.shangpin-neardate .getmovetime{width:40px;right:10px;}
.buttom-none{position:relative;}
.buttom-none .getmovetime{width:100%;left:0;}
.showmovetime,.showmovelist{padding-right:10px;font-size:1rem;}
.Timelist-bg{position:fixed;width:100%;height:100%;background-color:rgba(0,0,0,.7);top:0;left:0;z-index:998;}
.Timelist{position:fixed;width:100%;bottom:0;left:0;background-color:#fff;z-index:999;border-bottom:solid 1px #ddd;}
.Timelist button{border:0;}
.Time-title{text-align:center;padding:13px 0;font-size:1.6rem;color:#333;border-bottom:solid 1px #ddd;}
.Time-content{padding:10px;max-height:180px;overflow-y:scroll;}
.Time-content ul{text-align:center;padding:0;margin:0;font-size:1.4rem;}
.Time-content ul li{display:inline-block;min-width:70%;padding:5px 10px;border:solid 1px #eee;border-radius:10px;margin:5px 0;}
.Time-button{overflow:hidden;}
.Time-button>button{width:50%;box-sizing:border-box;border-top:solid 1px #ddd;float:left;font-size:1.6rem;color:#333;padding:15px 0;background-color:#fff;}
.Time-button>button:first-child{border-right:solid 1px #ddd;}
.line-clamp-2{display:-webkit-box!important;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;}
.hidden{display: none}
.flex{display:flex;}
.shangpin-addprice.flex{justify-content:space-between;align-items:center;}
.message-floor{ z-index: 12000;}
		/*3d素材*/
		.shangpin-content-second iframe{
			width: 100% !important;
			height: 375px !important;
			float: left;
		}
		.threed_show{
			width: 50px!important;height: 50px!important;
		}
		/*3d素材*/
		<?php
                //卖模式
              if($is_buy_sale_model){
                  if($is_promoters != 1 ){
                      //买98%，卖隐藏
                      echo '
                      .shangpin-footer .item2 .item2-panel:first-child{
                          width: 98%;
                      }
                      .shangpin-footer .item2 .item2-panel:last-child{
                          display: none;
                      }';
                  }
              }
              ?>
    </style>

</head>
<script>
function Hashtable() {
    this._hash = {};
    this._count = 0;
    this.add = function (key, value) {
        if (this._hash.hasOwnProperty(key)) return false;
        else {
            this._hash[key] = value;
            this._count++;
            return true;
        }
    }
    this.remove = function (key) {
        delete this._hash[key];
        this._count--;
    }
    this.count = function () {
        return this._count;
    }
    this.items = function (key) {
        if (this.contains(key)) return this._hash[key];
    }
    this.contains = function (key) {
        return this._hash.hasOwnProperty(key);
    }
    this.clear = function () {
        this._hash = {};
        this._count = 0;
    }
}
	ppriceHash = new Hashtable();
	var propertyids = "<?php echo $propertyids; ?>";
	<?php
	$proids			= "";
	$orgin_price	= 0;
	$now_price		= 0;
	$storenum		= 0;
	$unit			= "";
	$need_score		= 0;
	$pro_weight		= 0;
	$query = "select proids,orgin_price,now_price,storenum,need_score,weight,unit from weixin_commonshop_product_prices where product_id=" . $pid;
	$result = _mysql_query($query) or die('Query failed: ' . mysql_error());
	while ($row = mysql_fetch_object($result)) {
		$proids 		= $row->proids;
		$orgin_price 	= $row->orgin_price;
		$now_price 		= $row->now_price;
		$storenum 		= $row->storenum;
		$unit 			= $row->unit;
		$need_score 	= $row->need_score;
		$pro_weight 	= $row->weight;
		//订货系统门店或者子门店读取门店库存   订货系统4.0加  2017-11-08 lj
         if($o_shop_id>-1 || $o_branch_id>-1){
         	 $storenum = 0;
         	 //查询门店库存
             if($o_shop_id>-1){
                 $query_o_pro = "select opp.proids,(opp.store_count-opp.freeze_count) as store_count from orderingretail_proxy_product as opp RIGHT JOIN orderingretail_shop as os on os.proxy_id=opp.proxy_id 
where os.id=".$o_shop_id." and opp.customer_id=".$customer_id." and opp.product_id='".$pid."' and opp.proids='".$proids."' limit 1";
	 			 $result_o_pro = _mysql_query($query_o_pro) or die('Query failed111: ' . mysql_error());
	 				
	 			 while ($row_o_pro = mysql_fetch_object($result_o_pro)) {
	 			 	$storenum = $row_o_pro->store_count;
		 			 //查询该门店所有子门店库存
//		 			$query_branch_shop = "select id from orderingretail_shop_branch where shop_id='".$o_shop_id."' and customer_id=".$customer_id." and status='open' and isvalid=true";
//		 			$result_branch_shop = _mysql_query($query_branch_shop);
// 		 			while ($row_branch_shop = mysql_fetch_object($result_branch_shop)) {
//		 			 	$branch_id = $row_branch_shop->id;
//                     	$query_branch_pro = "select store_count-freeze_count from orderingretail_shop_branch_pro where branch_id=".$branch_id." and customer_id=".$customer_id." and product_id='".$pid."' and provalues='".$proids."' limit 1";
//			 			$result_branch_pro = _mysql_query($query_branch_pro);
//			 			while ($row_branch_pro = mysql_fetch_object($result_branch_pro)) {
//			 			 	$storenum += $row_branch_pro->store_count;
//			 			}
//		 			}
	 			 }
             }
             //查询子门店库存
             if($o_branch_id>-1){
                 $query_branch_pro = "select (store_count-freeze_count) as store_count from orderingretail_shop_branch_pro orderingretail_shop where branch_id=".$o_branch_id." and customer_id=".$customer_id." and product_id='".$pid."' and provalues='".$proids."' limit 1";
		 			 $result_branch_pro = _mysql_query($query_branch_pro);
		 			 while ($row_branch_pro = mysql_fetch_object($result_branch_pro)) {
		 			 	$storenum = $row_branch_pro->store_count;
		 			 }                	
             }
         }
		//根据活动类型改变产品属性价格
		switch($pro_act_type){
			
			//限购
			case 31:
				if($restricted_isout == 1 && $is_restricted == 1){
					$now_price = $restricted_price;
				}
			break;
			default :
			break;
		}
	?>
	var proids = "<?php echo $proids; ?>";
	var pridsarr = proids.split("_");
	//pridsarr.sort();
	var mlen = pridsarr.length;
	var pidarr2 = new Array();
	for (m = 0; m < mlen; m++) {
		var temp_s = parseInt(pridsarr[m], 10);
		pidarr2[m] = temp_s;
	}
	// pidarr2.sort();
	pidarr2.sort(function (x, y) {
		return parseInt(x) - parseInt(y);
	});
	proids = "";
	for (m = 0; m < mlen; m++) {
		var temp_s = parseInt(pidarr2[m], 10);
		if (proids == "") {
			proids = temp_s;
		} else {
			proids = proids + "_" + temp_s;
		}
	}

	var orgin_price = <?php echo $orgin_price; ?>;
	var now_price = <?php echo $now_price; ?>;
	var storenum = <?php echo $storenum; ?>;
	var unit = "<?php echo $unit; ?>";
	var need_score = '<?php echo $need_score; ?>';

	var pro_weight = '<?php echo $pro_weight; ?>';
	ppriceHash.add(proids,orgin_price+"_"+now_price+"_"+storenum+"_"+need_score+"_"+unit+"_"+pro_weight);
	<?php
	}
	?>
	selproHash = new Hashtable();
	function compare(a, b) {
		return (a - b);
	}

</script>
<?php 
//按最后一个产品属性查父属性排序
$l_proids_arr = explode('_', $proids);
$l_pro_p_arr  = [];
foreach ($l_proids_arr as $l_key => $l_value) {
	$query_pros  = "SELECT parent_id FROM weixin_commonshop_pros WHERE isvalid=TRUE AND id ='".$l_value."'";
	$result_pros = _mysql_query($query_pros) or die('Query_pros failed:'.mysql_error());
	while ($row_pros = mysql_fetch_object($result_pros)) {
		$l_pro_p_arr[] = $row_pros->parent_id;;
	}
}
$p_pro_str = implode('_', $l_pro_p_arr); 
?>
<body data-ctrl='true' >
	<div class="am-modal am-modal-confirm code-box" tabindex="-1" id="my-confirm">
	  <div class="am-modal-dialog" id='qr' >
	      <?php if(!$for_or && $over_time >0){?>
			    <i class="wx_loading_icon"></i>
		  <?php }else{?>
            <img src="/weixinpl/common_shop/common/tc_erweima/tc_erweima2.php?customer_id=<?php echo $customer_id ?>&user_id=<?php echo $user_id ?>" alt="">
		  <?php }?>
	  </div>
	  <div style="width: 100%; background: transparent none repeat scroll 0% 0%; height: 50px; line-height: 50px; text-align: center; float: left;">
	  	<div style=" height: 50px;">
	  		<span style="color:white;">长按图片保存二维码</span><img src="./images/refresh.png"  style="width:18px;margin-left:10%" onclick="refresh2('reflesh');"/>
	  	</div>
	  </div>
	</div>
	<!-- header部门-->
	<!-- <header data-am-widget="header" class="am-header am-header-default header">
		<div class="am-header-left am-header-nav header-btn" onclick="goBack();">
			<img class="am-header-icon-custom"  src="./images/center/nav_bar_back.png"/><span>返回</span>
		</div>
	    <h1 class="header-title">商品详情</h1>
	    <div class="am-header-right am-header-nav">
		</div>
	</header>
	<div class="topDiv" style="height:49px;"></div>  -->  <!-- 暂时屏蔽头部 -->
	<!-- header部门-->
	<div class="order_message hide" id="order_message" style="background-color: rgba(0,0,0,0.7);border-radius: 30px;height:30px;position:fixed;top: 52px;left: 10px;z-index: 10;">
		<img style="width: 24px;height: 24px;border-radius: 50%;vertical-align: middle;margin:2px 3px;display: inline-block;" src="/weixinpl/mshop/images/dalibao.jpg"/>
		<p style="color: #ffffff;font-size: 12px;display: inline-block;margin: 0;vertical-align: middle;padding-right: 7px;"><span style="width:46px;display:inline-block;vertical-align:middle;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;margin-right: 5px;">瞪圆德惠</span><span style="display:inline-block;vertical-align:middle;">下了一笔订单</span><span style="display:inline-block;vertical-align:middle;margin-left: 5px;">5分钟前</span></p>
	</div>
    <div id="containerDiv">
    	<!--titlebar -->
        <div class = "titlebar-container-div" >
        	<!-- 个人信息, 语言/频视 商品二维码 titlebar-->
            <div class = "titlebar-container-menu-div-top titlebar-container-menu-primary fix" >
            	<div class = "titlebar-container-menu-primary-first-item titlebar-container-menu-item">
					<a href="personal_center.php?customer_id=<?php echo $customer_id_en; ?>">
						<img class="am-header-icon-custom"   src ="./images/goods_image/20160051201.png">
						<span>个人中心</span>
					</a>
            	</div>
            	<div class = "titlebar-container-menu-primary-divider">
            		<img class = "title-divider-img"   src="./images/goods_image/line_nobg.png">
            	</div>
            	<div class = "titlebar-container-menu-primary-second-item titlebar-container-menu-item"  >
            		<img class="am-header-icon-custom"   src="./images/goods_image/20160051202.png" >
            		<span>语音/视频</span>
            	</div>
            	<div class = "titlebar-container-menu-primary-divider">
            		<img class = "title-divider-img"   src="./images/goods_image/line_nobg.png">
            	</div>
            	<?php if( $barcodes==1 ) {?>
            	<div onclick="show_personal_code();" class = "titlebar-container-menu-primary-third-item  titlebar-container-menu-item" >
            	<?php }else{ ?>
            	<div onclick="showcode();" class = "titlebar-container-menu-primary-third-item  titlebar-container-menu-item" >
            	<?php } ?>
            		<img class="am-header-icon-custom"   src="./images/goods_image/20160051203.png">
            		<span>二维码</span>
            	</div>
            </div>

            <!-- 个人信息, 语言/频视 商品二维码 titlebar-->

            <!-- 4-tab title -->
            <div class = "titlebar-container-menu-div titlebar-container-menu-secondary fix hidden" id = "titlebar-container-menu-secondary1">
            	<div id = "item1">
            		<div class = "menu-title"><span>详情</span></div>
            		<div class = "menu-underline"></div>
            	</div>
            	<div id = "item2">
            		<div class = "menu-title"><span style = "color:grey;">规格</span></div>
            		<div class = "menu-underline"></div>
            	</div>
            	<div id = "item3" >
            		<div class = "menu-title"><span style = "color:grey;">售后保障</span></div>
            		<div class = "menu-underline"></div>
            	</div>
            	<div id = "item4">
            		<div class = "menu-title"><span style = "color:grey;">评价</span><span style="color:#f4212b;">&nbsp;<?php echo $total_evaluate;?></span></div>
            		<div class = "menu-underline"></div>
            	</div>
            </div>
            <!-- 4-tab title -->
        </div>
        <!--titlebar -->
    </div>
    <div style="height:34px"></div> <!-- 占据上面框的高度 -->
    <!--content div-->
    <div class = "content">
    	<!-- 商品详情页1  -->
    	<div class = "shangpin-content shangpin-first">
	    	<div id="gallery-tab" class="gallery-tab-sty">
				<div data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='' style="position: relative">
					<?php
					if(!$d_link){//不是3d素材原样输出
					?>
						<ul id="scroll" class="am-slides">
							<?php
							foreach ($new_imgurl as $k => $v): ?>
								<li><img src="<?php echo $new_baseurl . $v['imgurl']; ?>?x-oss-process=image/resize,w_800"></li>
							<?php endforeach ; ?>
						</ul>
					<?php }else { ?>
							<img src="3d_logo.png"  style="width: 50px;height: 50px;position: absolute;top: 0;left: 0;
							<?php if ($is_show_tag_threed == '0'){ ?>display:none;; <?php } ?>" >
							<iframe src="<?php echo $d_link; ?>" width="100%" height='365px'style="float: left;"></iframe>
					<?php } ?>
				</div>
		    </div>
			<?php
			if($issnapup && !$is_collage_product){	//拼团产品不显示抢购时间
			?>
	    	<div  class = "shangpin-first-remain" style="display:none">
	    		<span id="time_name">距开始仅剩:</span>
	    		<span class = "information margin-space-span" id = "day" >0</span>
	    		<span class = "unit">天</span>
	    		<span class = "information" id = "hour" >0</span>
	    		<span class = "unit" >时</span>
	    		<span class = "information" id = "minute" >0</span>
	    		<span class = "unit" >分</span>
	    		<span class = "information" id = "second" >0</span>
	    		<span class = "unit" >秒</span>
	    	</div>
	    	<?php
			}
			?>
			<?php
			if($restricted_isout==1 && !$is_collage_product){	//拼团产品不显示抢购时间
			?>
	    	<div  class = "shangpin-first-remain" style="display:none">
	    		<span id="time_name">距开始仅剩:</span>
	    		<span class = "information margin-space-span" id = "day" >0</span>
	    		<span class = "unit">天</span>
	    		<span class = "information" id = "hour" >0</span>
	    		<span class = "unit" >时</span>
	    		<span class = "information" id = "minute" >0</span>
	    		<span class = "unit" >分</span>
				<span class = "information" id = "second" >0</span>
	    		<span class = "unit" >秒</span>
	    	</div>
	    	<?php
			}
			?>
			<?php
				if( $is_collage_product || $pro_act_type==22){//或积分兑换产品
			?>
			<div  class = "shangpin-first-remain-collage" style="display:none;">
	    		<span id="collage_time_name">距开始仅剩:</span>
	    		<span class = "information margin-space-span" id = "collage-day" >0</span>
	    		<span class = "unit">天</span>
	    		<span class = "information" id = "collage-hour" >0</span>
	    		<span class = "unit" >时</span>
	    		<span class = "information" id = "collage-minute" >0</span>
	    		<span class = "unit" >分</span>
	    		<span class = "information" id = "collage-second" >0</span>
	    		<span class = "unit" >秒</span>
	    	</div>
			<?php
				}
			?>
	    	<div class = "shangpin-neirong" >
				<div class="shangpin-neirong-left" style="max-width: 100%;display: inline-block;">
			    	<span class = "shangpin-neirong-content line-clamp-2" <?php if( !empty($collage_product_info) ){?>style="width: 100%;display: inline-block;font-size:16px;"<?php } ?>>

					<?php
					if( $isbrand_supply ){
					?>
						<span class = "shangpin-neirong-title">品牌</span>
					<?php
					}
					?>
					<?php
						echo $p_name;
					?>
					</span>

					<small class="line-clamp-2" style="font-size:14px;color:<?php if(!empty($short_introduce_color)){echo $short_introduce_color;}else{echo "#000000";}?>;">
					<?php echo $introduce; ?>
					</small>
				</div>

					<div class="shangpin-neirong-right ">
					<?php
						if( !empty($collage_product_info) ){
                            echo '<span class="collageTag">'.$collage_product_info['type_name'].'</span>';

						}
					?>

					</div>

	    	</div>

	    	<div class = "shangpin-price">

		    	<span class = "curprice">

                <?php if($integral_type == 2 && $integral_result['errcode']==0 && $integral_result['data'][$pid]['integral_p']>0  ){ 
	                	if( $shop_integral_onoff == 1 ){
	                		echo $integral_result['data'][$pid]['integral_p'].$shop_int_name;
	                	}else{
	                		echo $integral_result['data'][$pid]['store_integral_p'].$store_int_name;
	                	}
                	  	if($integral_result['data'][$pid]['money_p']>0){ ?>+ <?php if(OOF_P != 2) echo OOF_S ?><?php echo $integral_result['data'][$pid]['money_p']; ?><?php if(OOF_P == 2) echo OOF_S ?>
                <?php } }else{ ?>

				<?php if(OOF_P != 2) echo OOF_S ?>
				<?php echo $show_now_price; ?>
				<?php if(OOF_P == 2) echo OOF_S ?>

                <?php } ?>
				</span>
		    	<?php if($is_show_original){ ?><span class = "primeprice">
				<?php if(OOF_P != 2) echo OOF_S ?>
				<?php echo $p_orgin_price; ?>
				<?php if(OOF_P == 2) echo OOF_S ?>
				</span><?php } ?>
                <?php
				if( $isOpenSales > 0 ){
				?>
		    	<div id = "yishou">
		    		<span>已售<?php echo $total_sales; ?></span>
		    	</div>
				<?php
				}
				?>
		    	<div class = "div-float-right">

		    	</div>
		    	<div class="curprice-small line-clamp-2" style="color:<?php if(!empty($remark_color)){echo $remark_color;}else{echo "#000000";}?>;"><?php echo $remarks; ?></div>
                
                
                
	    	</div>
	    	<div class = "shangpin-addinfo" >

                <?php if($payondelivery_id && $ispay_on == 1 && empty($collage_product_info)){  ?>
                    <span id = "newtag">货到付款</span>
                <?php }  ?>

                <?php
                if( $showAndCashback['display'] == 1 or ( $is_promoters > 0 and $is_commission_cal > 0 ) ){
                    if( $showAndCashback['display'] == 1 ){
                        if( $showAndCashback['cashback_m'] > 0 && $is_cashback == 1 ){
                ?>
                    <span id = "newtag">赠<?php if(OOF_P != 2) echo OOF_S ?><?php echo $showAndCashback['cashback_m'];?><?php if(OOF_P == 2) echo OOF_S ?></span>
                <?php
                        }
                        if(  $is_currency && $back_currency > 0 ){
                ?>
                    <span id = "newtag">赠<?php echo $back_currency;?><?php echo $custom;?></span>
                <?php
                        }
                    }
                }
                ?>

                <?php if($integral_type == 1 && $integral_result['errcode']==0 && $integral_result['data'][$pid]['consume_integral_p']>0 ){ ?>
                    <span id = "newtag">送<?php echo $shop_int_name;?><?php echo $integral_result['data'][$pid]['consume_integral_p']; ?></span>
                <?php } ?>

                <?php if( $isOpenCurrency > 0 and  $currency_price > 0 ){ ?>
                    <span id = "newtag">可用<?php echo $custom;?><?php echo $currency_price; ?></span>
                <?php } ?>

                <?php if( $renewal_id > 0 && $renewal_time > 0 ){?>
                    <span id="newtag">续费<?php echo $renewal_time;?>天</span>
				<?php } ?>

                <?php if( $isvp == 1 and $vp_score > 0 ){ ?>
                    <span id = "newtag">vp:<?php echo $vp_score; ?></span>
                <?php } ?>

                <?php if( $isshowdiscount == 1 and 10 > $pro_discount and $pro_discount > 0 ){ ?>
                    <span id = "newtag"><?php echo $pro_discount; ?>折</span>
                <?php } ?>

               <?php if($is_free_shipping==1){ ?>
                    <span id = "newtag">包邮</span>
                <?php } ?>

                <?php if($is_invoice==1){ ?>
                    <span id = "newtag">发票</span>
                <?php } ?>

                <?php if ( $delivery_id > 0 ) { ?>
                    <span id = "newtag">预</span>
                <?php } ?>

                <?php if($tax_type > 1){?>
                <span id = "newtag">税</span>
                <?php }?>

                <?php //if(($is_restricted==1) && ($restricted_isout==1)){?>
                    <!--span id = "newtag">限</span-->
                <?php// }?>
                
                <?php if($islimit || $restricted_isout){?>
                    <span id = "newtag">限</span>
				<?php }?>

                <?php if( ( 1 == $is_charitable) and ( 0 < $charitable_price ) ){?>
                    <span id = "newtag">捐<?php if(OOF_P != 2) echo OOF_S ?><?php echo $charitable_price;?><?php if(OOF_P == 2) echo OOF_S ?></span>
                <?php }?>
                
	    	</div>
	    	<!--优惠券 start-->
			<?php 
			if($result_coupon_num>0 && $link_coupons>-1 && $is_coupon>0){?>
                <div class="shangpin-addprice flex" onclick="show_coupon()" >
	                <span>
	                    <a style="font-size:14px;background-color:red;color:white;line-height:1;padding:3px 5px 2px 5px;display:inline-block;vertical-align:middle;">优惠券</a>
	                    <a style="padding-left:10px;color:gray;font-size:15px;">领取优惠券</a>
	                </span>
                	<span class="coupon_get"><img src="./images/vic/right_arrow.png" width="8" height="14" style="margin:-4px 0 0 0;"></span>
                </div>
			<?php }?>
			<!--优惠券 end-->
			<?php
				//预到货
				$aog_id = -1;
				$is_aog = 0;		//是否预到货产品
				$is_available = 0;	//是否有货
				$query_aog = "SELECT id FROM aog_products_t WHERE pid=".$pid." AND customer_id=".$customer_id." AND isvalid=true";
				$result_aog = _mysql_query($query_aog) or die('Query_aog failed:'.mysql_error());
				while ( $row_aog = mysql_fetch_object($result_aog) ) {
					$aog_id = $row_aog -> id;
				}

				if ( $aog_id > 0 ) {
					$is_aog = 1;
					//获取默认收货地址
					$aog_p = '';
					$aog_c = '';
					$aog_a = '';
					$aog_d = '';
					if ( $user_id > 0 ) {
						$query_default = "SELECT location_p, location_c, location_a, address FROM weixin_commonshop_addresses WHERE user_id=".$user_id." AND is_default=1 AND isvalid=true";
						$result_default = _mysql_query($query_default) or die('Query_default failed:'.mysql_error());
						while ( $row_default = mysql_fetch_object($result_default) ) {
							$aog_p = $row_default -> location_p;
							$aog_c = $row_default -> location_c;
							$aog_a = $row_default -> location_a;
							$aog_d = $row_default -> address;
						}
					}

					$hours_time = 0;	//到货时间（小时）
					$aog_date = '';
					if ( $aog_p == '' ) {
						//没有默认收货地址则默认北京市
						$aog_p = '北京市';
						$aog_c = '北京市';
						$aog_a = '东城区';
						$query_aog_area = "SELECT is_available, hours_time, province, city, area FROM aog_products_pros_areas WHERE pid=".$pid." AND pros='' AND province='北京市' AND city='北京市' AND area='东城区' AND isvalid=true LIMIT 1";
						$result_aog_area = _mysql_query($query_aog_area) or die('Query_aog_area failed'.mysql_error());
						while ( $row_aog_area = mysql_fetch_object($result_aog_area) ) {
							$is_available 	= $row_aog_area -> is_available;
							$hours_time 	= $row_aog_area -> hours_time;
							$aog_date = date('m月d日', strtotime('+'.$hours_time.' hours'));
						}
					} else {
						$query_aog_area = "SELECT is_available, hours_time FROM aog_products_pros_areas WHERE pid=".$pid." AND pros='' AND isvalid=true AND province='".$aog_p."' AND city='".$aog_c."' AND area='".$aog_a."' AND diy_area='".$aog_d."'";
						$result_aog_area = _mysql_query($query_aog_area) or die('Query_aog_area failed'.mysql_error());
						while ( $row_aog_area = mysql_fetch_object($result_aog_area) ) {
							$is_available 	= $row_aog_area -> is_available;
							$hours_time 	= $row_aog_area -> hours_time;
							$aog_date = date('m月d日', strtotime('+'.$hours_time.' hours'));
						}
					}
					if ( $is_available ) {
						$is_available_str = '有货';

					} else {
						$is_available_str = '无货';
					}


			?>
			<div class="shangpin-address" onclick="changeAddress();">
				<div class="shangpin-address-left">送至</div>
				<div class="shangpin-address-right">
					<div class="shangpin-address-text">
						<img src="./images/icon-position.png" class="position-icon">
						<span class="ellipsis aog_address"><?php echo $aog_p.$aog_c.$aog_a.$aog_d;?></span>
						<img src="./images/hjian.png" class="after-icon">
					</div>
					<div class="shangpin-address-small"><span class="skin-color is_available"><?php echo $is_available_str;?></span><span class="available_tip" <?php if ( !$is_available || $aog_date =='' ) { ?>style="display: none;"<?php } ?>>，预计(<span class="aog_date"><?php echo $aog_date;?></span>)送达</span></div>
				</div>
			</div>
			<?php
				//获取所有四级区域
				$aog_area = [];
				$query_all_area = "SELECT pros, province, city, area, diy_area FROM aog_products_pros_areas WHERE pid=".$pid." AND isvalid=true";
				$result_all_area = _mysql_query($query_all_area) or die('Query_all_area failed:'.mysql_error());
				while ( $row_all_area = mysql_fetch_object($result_all_area) ) {
					$pros 		= $row_all_area -> pros;
					$province 	= $row_all_area -> province;
					$city 		= $row_all_area -> city;
					$area 		= $row_all_area -> area;
					$diy_area 	= $row_all_area -> diy_area;

					if ( $pros == '' ) {
						$pros = -1;
					}

					$aog_area[$pros][$province.$city.$area][] = $diy_area;
				}

			?>
			<div class="changeAddress" onclick="offAddress();" ></div>
			<div class="Address-box">
				<div class="Address-title">
					<span onclick="offAddress();"><img src="./images/ico_zuo.png"></span>
					请选择区域地址
				</div>
				<div class="Address-list">
					<span>省市区</span>
					<ul>
						<li><select id="WSY_provinces" name="WSY_provinces"></select></li>
						<li><select id="WSY_city" name="WSY_city"></select></li>
						<li><select id="WSY_area" name="WSY_area"></select></li>
					</ul>
				</div>
				<div class="Address-list">
					<span>街 道</span>
					<p><select id="WSY_Street"></select></p>
				</div>
				<div class="Address-btn">
					<button class="skin-bg" onclick="up_Address();">确认提交</button>
				</div>
			</div>
			<script>
				var aog_area = eval(<?php echo json_encode($aog_area);?>),
					selectedPros = '',
					is_available = <?php echo $is_available;?>,
					aog_p = '<?php echo $aog_p;?>',
					aog_c = '<?php echo $aog_c;?>',
					aog_a = '<?php echo $aog_a;?>',
					aog_d = '<?php echo $aog_d;?>';

				$('#WSY_provinces, #WSY_city, #WSY_area').change(function () {
					var _aog_p = $('#WSY_provinces').val(),
						_aog_c = $('#WSY_city').val(),
						_aog_a = $('#WSY_area').val(),
						_aog_address = _aog_p+_aog_c+_aog_a;

					var _pros = '';
					if ( selectedPros == '' ) {
						_pros = -1;
					} else {
						_pros = selectedPros;
					}

					var aog_html = '<option value="">请选择</option>';
					$('#WSY_Street').find('option').remove();


					if ( Object.getOwnPropertyNames(aog_area).length > 0 ) {
						var _aog_area = [];
						for ( i in aog_area ) {
							_aog_area[i] = [];
							for ( j in aog_area[i] ) {
								 var str = i + '=' + aog_area[i][j];
								_aog_area[i][j] = aog_area[i][j];
							}
						}
						try {
							if ( _aog_area[_pros] != 'undefined' && _aog_area[_pros][_aog_address] != 'undefined' ) {
								_aog_d = _aog_area[_pros][_aog_address];

								for ( i in _aog_d ) {
									if ( _aog_d[i] == '' ) {
										continue;
									}
									aog_html += '<option value="'+_aog_d[i]+'">'+_aog_d[i]+'</option>';
								}
							}
						} catch (e) {

						}



					}
					$('#WSY_Street').append(aog_html);

				})

				$(function () {
					// 选择地址begin
					new PCAS('WSY_provinces', 'WSY_city', 'WSY_area', '<?php echo $aog_p;?>', '<?php echo $aog_c;?>', '<?php echo $aog_a;?>',1);
					$('#WSY_Street').val(aog_d);
					// 选择地址end
				})
			</script>
			<?php
				}
			?>

 	    	
			<?php
			$delivery_datetime = [];
			if ( $delivery_id > 0 ) {
		?>
		<div class="delivery_id" style="display: none">
			<div class = "shangpin-line"></div>
			<input type="hidden" value="" id="preDeliveryDate"/>
			<input type="hidden" value="" id="preDeliveryTime"/>
			<div class="shangpin-addprice buttom-none">
				<input type="text" class="getmovetime">
				<span style="font-size:15px;color:#707070;">时间选择:</span>
				<span class="coupon_get"><span class="showmovetime"></span><span class="showmovelist"></span><img src="./images/vic/right_arrow.png" width="8" height="14" class="coupon_get_img"></span>
				<div class="clear_float"></div>
			</div>
			<div class="shangpin-neardate">
				<input type="text" class="getmovetime">
				<ul>
				<?php
					$delivery_limit = 0;
					ksort($pre_delivery_time['delivery_time']);	//日期排序
					foreach ( $pre_delivery_time['delivery_time'] as $key => $val ) {
						//去掉月份的0
						$key_arr = explode('-', $key);
						if ( $key_arr[1] < 10 ) {
							$key_arr[1] = str_replace('0', '', $key_arr[1]);
						}
						$key_new = implode('-', $key_arr);
						$delivery_datetime[] = array('style'=>1, 'day'=>$key_new);
						if ( $delivery_limit >= 4 ) {
							continue;
						}
						$delivery_date_new = date('m-d', strtotime($key));
				?>
					<li date="<?php echo $key;?>"><a onclick="addTimeList('<?php echo $key;?>');">
						<p class="time"><?php echo $delivery_date_new;?></p>
						<p class="price"><?php echo $val['week'];?></p>
					</a></li>
				<?php
						$delivery_limit++;
					}

				?>
				</ul>
				<div class="allDate">
					全部<br>日期
				</div>
			</div>
			<div class = "shangpin-line"></div>
		</div>
	    	<?php
				}
				if( $showAndCashback['display'] == 1 or ( $is_promoters > 0 and $is_commission_cal > 0 ) ){
			?>
                        <div class = "shangpin-addprice" style="border-bottom:1px solid #d1d1d1">

				<?php
				if( $is_promoters > 0 and $is_commission_cal > 0 /* and $issell_model==2 */){
				?>

				<div class="span">
				<?php if($is_collage_product == 1){?>
					<div onclick="reckon_commision()">
						<img  class="count" src="images/goods_image/count.png">
						<img class="countld" src="images/goods_image/countld.png">
						<span class="countDet"><?php echo $commission_cal_content;?></span>
					</div>

				<?php }else{?>
					<div onclick="reckon_commision()">
						<img  class="count" src="images/goods_image/count.png">
						<img class="countld" src="images/goods_image/countld.png">
						<span class="countDet"><?php echo $commission_cal_content;?></span>
					</div>

				<?php }?>
				</div>
				<?php
				}
				?>
		    </div>
		    <div class = "shangpin-line"></div>
 			<?php
			}
			?>

			<?php if($link_package>0){?>
			<div class="shangpin-line"></div>
			<a href="./product_detail_gift.php?package_id=<?php echo $link_package; ?>">
			<div class="shangpin-addprice" style="width: 100%;height: auto;">
				<div class="span">
					<img style="width: 100%;padding-right: 8px;" src="<?php echo $link_package_img; ?>">
				</div>
			</div>
			</a>
			<?php } ?>
			<?php
				if( !empty($explain) and $explain['status'] == 1 ){
			?>
			<div class = "shangpin-panel3" >
				<div class="det">
					<span class="exp"><?php echo $explain['title'];?></span><div class="icon"><span>!</span></div>
					<img class="detBtn" src="images/collage_activity/xiala_icon.png">
					<div class="detBottom">
						<p class="time">活动时间：<?php echo $collage_product_info['start_time'].' - '.$collage_product_info['end_time'];?></p>
						<div class="detCell"><?php echo $explain['content'];?></div>
					</div>
				</div>
			</div>
			<div class="shangpin-line" ></div>
			<?php
				}
			?>
			<?php
				if( !empty($groups) ){
			?>
			<div class = "shangpin-panel3" >
				<div class="det" style="max-height:255px;overflow:scroll;">
					<span class="exp">小伙伴的拼团,你可以参加噢!</span>
					<a href="./collageActivities/product_list_view.php?customer_id=<?php echo $customer_id_en;?>&op=popularity">
						<img class="detBtn2" src="images/collage_activity/icon2.png" />
						<span class="expMore">人气拼团</span>
					</a>
				<?php
					foreach( $groups as $k => $v ){
						if( empty($v['weixin_headimgurl']) ){
							$v['weixin_headimgurl'] = '../../common/custom_temp/images/username.png';
						} else {
							$pos = strpos($v['weixin_headimgurl'],"http://");
							$pos2 = strpos($v['weixin_headimgurl'],"https://");

							if($pos===0 || $pos2===0){

							}else{
								$pos1 = strpos($v['weixin_headimgurl'],"../../../");
								$pos2 = strpos($v['weixin_headimgurl'],"../../");
								$pos3 = strpos($v['weixin_headimgurl'],"../");
								if($pos1===0){
									$v['weixin_headimgurl'] = substr($v['weixin_headimgurl'],9);
								}elseif($pos2===0){
									$v['weixin_headimgurl'] = substr($v['weixin_headimgurl'],6);
								}elseif($pos3===0){
									$v['weixin_headimgurl'] = substr($v['weixin_headimgurl'],3);
								}
								$v['weixin_headimgurl'] = BaseURL.$v['weixin_headimgurl'];
							}
						}
				?>
					<div class="detCell3">
						<img class="headImg2" src="<?php echo $v['weixin_headimgurl'];?>" />
						<div class="box1">
							<p class="line1"><?php echo $v['weixin_name']?$v['weixin_name']:$v['name'];?></p>
							<p class="line2"><?php echo $v['province'];?></p>
							<p class="line3">剩余时间<span class="rest_time rest_time_<?php echo $v['id']?>" data-id="<?php echo $v['id'];?>" data-end_time="<?php 
                            if($v['endtime']=='0000-00-00 00:00:00'){
                                echo strtotime($v['end_time']);
                            }else{
                                echo strtotime($v['endtime']);
                            }
                             ?>"></span></p>
						</div>
						<div class="box2">
							<p class="top">还差<span><?php echo $v['success_num']-$v['join_num'];?></span>人</p>
							<a href="./collageActivities/activities_detail_view.php?customer_id=<?php echo $customer_id_en;?>&group_id=<?php echo $v['id'];?>"><p class="bottom ">去参团<img src="images/collage_activity//icon2_white.png" /> </p></a>
						</div>
					</div>
				<?php
					}
				?>
				</div>
			</div>
			<div class="shangpin-line" ></div>
			<?php
				}
			?>
		    <div class = "shangpin-panel3" >
		    	<div  class = "shangpin-panel3-item1">
					<img id = "url2" src="<?php echo $brand_logo; ?>" >
					<span id = "name"><?php echo $brand_supply_name; ?></span>
					<?php
					if( $advisory_flag ){
					?>
					<div class = "shangpin-panel3-item1-content">
						<a href="tel:<?php echo $brand_tel?>" ><img id = "phone" src="./images/goods_image/phone_1.png" width="25" height="25" ></a>
						<span></span>
					</div>
					<?php
					}
					?>
		    	</div>
			<?php
			if( $sid > 0 ){
				if( $isbrand_supply ){
			?>
				<div class="s-line"></div>
		    	<div class = "shangpin-panel3-item2">
		    		<div class = "shangpin-panel3-item2-left1">
		    			<div class = "shangpin-panel3-item2-left1-item1" ><span id="collect_num"><?php echo $collect_num?$collect_num:0; ?></span></div>
		    			<div class = "shangpin-panel3-item2-left1-item1" ><span style = "color:#5f666b;" >收藏</span></div>
		    		</div>
		    		<div class = "shangpin-panel3-item2-left1">
		    			<div class = "shangpin-panel3-item2-left1-item1"><span><?php echo $pro_num?$pro_num:0; ?></span></div>
		    			<div class = "shangpin-panel3-item2-left1-item1"><span style = "color:#5f666b;">全部商品</span></div>
		    		</div>
		    		<div class = "shangpin-panel3-item2-left1">
		    			<div class = "shangpin-panel3-item2-left1-item1"><span><?php echo $comment_num?$comment_num:0; ?></span></div>
		    			<div class = "shangpin-panel3-item2-left1-item1"><span style = "color:#5f666b;">评价</span></div>
		    		</div>
		    	</div>
		    	<div class = "shangpin-panel3-item3">
		    		<div class = "shangpin-panel3-wrapper">
					<?php
						$scount = 0;	//是否已收藏：0否，1是
						$query_s = 'select count(1) as scount from weixin_user_collect where isvalid=true and collect_id='.$sid.' and customer_id='.$customer_id.' and collect_type=2 and user_id='.$user_id;
						$result_s = _mysql_query($query_s) or die('query_s failed'.mysql_error());
						while($row_s = mysql_fetch_object($result_s)){
							$scount = $row_s->scount;
						}
					?>
		    			<button id = "bookmark" type="button" class="am-btn store-button  collect_shop_1" onclick="collect(<?php echo $sid;?>,2,'add',0)"    style="<?php if($scount>0){echo 'display:none;';}?>">收藏店铺</button>
		    			<button id = "bookmark_collected" class="am-btn store-button collect_shop_2" onclick="collect(<?php echo $sid;?>,2,'del',0)" style="<?php if(0 == $scount){echo 'display:none;';}?>">已收藏</button>
		    		</div>
		    		<div class = "shangpin-panel3-wrapper">
                    <?php if($shop_jump_type==0){

                    ?>
						<a href="my_store/my_store.php?supplier_id=<?php echo $sid?>&customer_id=<?php echo $customer_id_en; ?>">
							<button id = "entershop" type="button" class="am-btn store-button  " >进入店铺</button>
						</a>
                    <?php }else{
                    ?>
                        <a href="my_store/my_store_list.php?supplier_id=<?php echo $sid?>&customer_id=<?php echo $customer_id_en; ?>&product_type=1">
							<button id = "entershop" type="button" class="am-btn store-button  " >进入店铺</button>
						</a>
                    <?php }?>
		    		</div>
					<div class = "shangpin-panel3-wrapper">
						<a class="chat"  onclick="locatP(4);"><button id = "entershop" type="button" class="am-btn store-button  " >联系客服</button></a>
					</div>
		    	</div>
			<?php
				}
			}
			?>
		    </div>
		    <div class = "shangpin-line"></div>

			<?php
			if( $is_guess_you_like && $is_collage_product == 0 ){		//拼团不显示猜你喜欢
			?>

		    <div class = "shangpin-panel4">
		    	<div id = "shangpin-panel4-item1"> 猜你喜欢</div>
		    	<div id = "shangpin-panel4-item2">
				<?php?>
			    </div>
			    <div id = "shangpin-panel4-item3">
		    		<div class = "shangpin-panel4-item3-wrapper">
		    			<button id = "changeset" type="button" class="am-btn ">换一组</button>
		    		</div>
		    		<div class = "shangpin-panel4-item3-wrapper">
						<a href="list.php?customer_id=<?php echo $customer_id_en; ?>&pid=<?php echo $pid;?>&op=morelike">
							<button id = "seemore" type="button" class="am-btn " >查看更多</button>
						</a>
		    		</div>
		    	</div>
		    </div>
			<?php
			}
			?>
		    <div class = "shangpin-line shangpin-panel4_xian"></div>
    	</div>
    	<!-- 商品详情页1 -->

    	<!-- 商品详情页2  -->
    	<!--  详情 -->
    	<div class = "titlebar-container-menu-div titlebar-container-menu-secondary" id = "secondmenu2">
        	<div id = "item1">
        		<div class = "menu-title"><span>详情</span></div>
        	</div>
        	<div id = "item2">
        		<div class = "menu-title"><span >规格</span></div>
        	</div>
        	<div id = "item3" >
        		<div class = "menu-title"><span >购买记录</span></div>
        	</div>
			<?php
			if( $is_showdiscuss > 0 ){
			?>
        	<div id = "item4">
        		<div class = "menu-title"><span >评价</span><span style="color:#f4212b;">&nbsp;<?php echo $good_level+$meu_level+$bad_level;?></span></div>
        	</div>
			<?php
			}
			?>
        </div>
    	<div class = "shangpin-content shangpin-second1 shangpin-content-second" style="position: relative;" >
			<?php echo html_entity_decode($description);?>
    	</div>
    	<!--  详情-->

    	<!-- 规格 -->
    	<div class = "shangpin-content shangpin-second2 shangpin-content-second">
	    	<?php echo $specifications;?>
    	</div>
    	<!-- 售后保证 -->
		<?php $res = GetProductStat($pid);?>
		<div style="height:40px;background:rgb(2, 179, 0);vertical-align:middle;line-height:40px;font-weight:blod"><span style="color:white">&nbsp&nbsp&nbsp共有<?php echo $res['data']['people_count']?>人购买，累计销售:<?php echo $res['data']['product_count']?>份</span></div>
    	<div class = "shangpin-content shangpin-second3 shangpin-content-second">
			
			<?php 
				$res = GetProductRecode($pid);	//获取记录集					
			?>
			<ul class="am-list am-list-static am-list-border">		
				  
				<?php if($res['code'] == 'success')
						{
							foreach($res['data'] as $val)
							{
				?>				
								  <li style="height:40px;font-size:14px">
									<div class="am-u-sm-5"><img class="am-img-thumbnail" style="border-radius: 50%;height:20px;width:20px;" src="<?php echo $val['weixin_headimgurl']?>"><?php echo $val['weixin_name']?></div>
									<div class="am-u-sm-2"><?php echo $val['rcount']?></div>
									<div class="am-u-sm-5"><?php echo $val['paytime']?></div>				
								  </li>	
					<?php }
						}
					?>

			</ul>	    	
    	</div>
    	<!--评价-->
		<?php
		if( $is_showdiscuss > 0 ){
		?>
    	<div class = "shangpin-content shangpin-second4 shangpin-content-second">
			<div class = "item-top" >
				<span >商品好评率:</span>
				<span class = "shangpin-second4-item1-span"><?php if($total_evaluate!=0){echo round(100*($good_level/$total_evaluate),2)."%";}else{echo '0';}?></span>
			</div>
			<div class = "item" class = "div-float-left">
				<div class = "item2-cell1 colorchange" PL="0">
				  <div class = "shangpin-second4-item2-cell">全部</div>
				  <div class = "shangpin-second4-item2-cell">(<?php echo $total_evaluate;?>)</div>
				</div>
				<div class = "item2-cell2 colorchange" PL="1">
				  <div class = "shangpin-second4-item2-cell2">好评</div>
				  <div class = "shangpin-second4-item2-cell2">(<?php echo $good_level;?>)</div>
				</div>
				<div class = "item2-cell3 colorchange" PL="2">
				  <div class = "shangpin-second4-item2-cell2">中评</div>
				  <div class = "shangpin-second4-item2-cell2">(<?php echo $meu_level;?>)</div>
				</div>
				<div class = "item2-cell4 colorchange" PL="3">
				  <div class = "shangpin-second4-item2-cell2">差评</div>
				  <div class = "shangpin-second4-item2-cell2">(<?php echo $bad_level;?>)</div>
				</div>
			</div>
			<div style="clear:both;"></div>
			<div style="position: relative;">
				<div id="wrapper">
					<div id="scroller">
						<ul id="thelist">
						</ul>
				<p id="pinterestMore" style="display: none;">----- 正在加载 -----</p>
				<p id="pinterestDone" style="display:none;">----- 评论已加载完毕 -----</p>
					</div>
				</div>
			</div>

    		<!-- <div id = "pingjia-content">

			</div> -->
    	<!--评价-->
    	<!-- 商品详情页2  -->
		</div>
		<?php
		}
		?>
    <!--content div-->

    <!--悬浮按钮-->
	<?php
	$fun = "mshop_product_detail";
	require_once('../common/utility_setting_function.php');
	$nav_is_publish = check_nav_is_publish($fun,$customer_id);
	$is_publish = check_is_publish(2,$fun,$customer_id);
	include_once('float.php');
	?>
	<!--悬浮按钮-->

	<!--引导关注 绑定手机 下载app按钮-->
	<?php include '../common_shop/jiushop/share.php';?>
	<!--引导关注 绑定手机 下载app按钮-->

    <!-- footer content -->
	<?php
		if( $is_collage_product ){ //如果是团购则不进入买卖模式
	?>
	<div class = "shangpin-footer" style="text-align: center;line-height: 62px;">
	<?php
		if( $sid > 0 && (0 == $is_admin_closed || 0== $is_owner_closed) ){
	?>
		<button id = "singleBuy" type="button" class="am-btn  am-btn-danger item2-panel-button text-hidden" disabled="disabled"><span>商家休息中</span><span>不能单独购买</span></button>
	<?php
		} else {
	?>
		<button id="singleBuy" onclick="if(!showlevel(<?php echo $is_allow_buy;?>)){return;}groupBuyType=1;removeActive();showBuyDiv(2);" type="button" class="am-btn skin-b2 am-btn-danger item2-panel-button" disabled="disabled" >
		<span>
		<?php if(OOF_P != 2) echo OOF_S ?>
		<?php echo $show_now_price;?>
		<?php if(OOF_P == 2) echo OOF_S ?>
		</span><span>单独购买</span></button>
	<?php
		}
		//成团人数
		$group_num = $collage_product_info['group_size'];
		if($collage_product_info['success_num'] != -1){
			$group_num = $collage_product_info['success_num'];
		}

	?>
		<button id="collageBuy" onclick="groupBuyType=2;removeActive();showBuyDiv(2);" type="button" class="am-btn skin-b1 am-btn-danger item2-panel-button" disabled="disabled">

		<span>
		<?php if(OOF_P != 2) echo OOF_S ?>
		<?php echo $groupPrice;?>
		<?php if(OOF_P == 2) echo OOF_S ?>
		</span>

		<span><?php echo $group_num;?>人团</span></button>
    </div>
	<?php } else { ?>

    <?php if($isout == 1){?>
        <!--当商品下架时显示提示-->
        <div style="width:100%;height:56px;line-height:56px;background-color: #0a0a0a;opacity: 0.7;color:#fff;position: fixed;bottom:64px;text-align: center;">
            该商品已经下架！
        </div>
    <?php }?>


    <div class = "shangpin-footer">
	<?php
		//是否已收藏产品
		if( $user_id ){
			$rcount = 0;
			$query_c = "select count(1) as rcount from weixin_user_collect where isvalid=true and customer_id=".$customer_id." and user_id=".$user_id." and collect_id=".$pid." and collect_type=1";
			$result_c = _mysql_query($query_c) or die('query_c failed'.mysql_error());
			while($row_c = mysql_fetch_object($result_c)){
				$rcount = $row_c->rcount;
			}
		}
	?>
    	<div class = "item1 collect_1" id = "item1-cell1 collect_1" onclick="collect(<?php echo $pid.",1,'add',".$sid;?>)" style="<?php if($rcount>0){echo 'display:none;';}?>">
    		<div class = "shangpin-footer-item1-row1">
    			<img src = "./images/goods_image/2016042701.png" >
    		</div>
    		<div class = "shangpin-footer-item1-row2">
    			<span>收藏</span>
    		</div>
    	</div>
		<div class = "item1 collect_2" id = "item1-cell1 collect_2" onclick="collect(<?php echo $pid.",1,'del',".$sid;?>)" style="<?php if($rcount<=0){echo 'display:none;';}?>">
    		<div class = "shangpin-footer-item1-row1">
    			<img src = "./images/goods_image/collect.png">
    		</div>
    		<div class = "shangpin-footer-item1-row2">
    			<span style="color:#ff8430">已收藏</span>
    		</div>
    	</div>




    	<?php	//当产品属于品牌供应商才能进店
		$supply_url = "";
		if( $isbrand_supply ){
			$supply_url = "./my_store/my_store.php?supplier_id=".$sid."&customer_id=".$customer_id_en;
		?>
    	<div class = "item1 button buttonclick">
			<a href="<?php echo $supply_url;?>">
				<div class = "shangpin-footer-item1-row1">
					<img src = "./images/goods_image/2016042702.png"  >
				</div>
				<div class = "shangpin-footer-item1-row2 pt1">
					<span>进店</span>
				</div>
			</a>
    	</div>
		<?php }?>
    	<div class = "item1  button buttonclick">
			<a href="order_cart.php?customer_id=<?php echo $customer_id_en;?>&shop_id=<?php echo $o_shop_id;?>">
				<div class = "shangpin-footer-item1-row3">
					<img src = "./images/goods_image/2016042703.png" >
					 <span id = "badge-span" style =""></span>
				</div>
				<div class = "shangpin-footer-item1-row2 pt1">
					<span>购物车</span>
				</div>
    		</a>
    	</div>
		<?php
		/*echo $is_allow_buy.'<br>';
		echo $isbrand_supply.'<br>';
		echo $is_virtual.'<br>';
		echo $is_buy_sale_model.'<br>';
		echo $sid.'<br>';
		echo $is_admin_closed.'<br>';
		echo $is_owner_closed.'<br>';*/

		?>
        <?php if($isout == 0){?>
            <?php if($is_allow_buy == 1){?>
            <div class = "item2" <?php if(!$isbrand_supply)echo 'style="padding-left: 95px;"';?>>
                <div class = "item2-panel">
                    <?php if($is_virtual > 0  ){	//虚拟产品不能加入购物车?>
                        <?php if($is_buy_sale_model == 1){  //是否是买卖模式，0：默认模式，1：买卖模式?>

                            <button id = "joinCar" onclick="showBuyDiv(1,1);" type="button" class="am-btn am-btn-warning item2-panel-button skin-b1" disabled="disabled">买</button>

                        <?php }else{?>

                            <button id = "button4" onclick="showlevel(<?php echo $is_allow_buy;?>);showBuyDiv(1,1);" type="button" class="skin-b1 am-btn am-btn-warning item2-panel-button text-hidden" disabled="disabled">加入购物车</button>

                        <?php }?>
                    <?php } else {?>

                        <?php if($sid < 0){ ?>
                            <?php if($is_buy_sale_model == 1){ ?>

                                <button id = "joinCar" onclick="showBuyDiv(1,1);" type="button" class="skin-b1 am-btn am-btn-warning item2-panel-button" disabled="disabled">买</button>

                            <?php }else{?>

                                <button id = "joinCar" onclick="showBuyDiv(1);" type="button" class="skin-b1 am-btn am-btn-warning item2-panel-button" disabled="disabled">加入购物车</button>

                            <?php }?>

                        <?php }else if($sid > 0 && 1 == $is_admin_closed && 1== $is_owner_closed){ ?>
                            <?php if($is_buy_sale_model == 1){ ?>

                                <button id = "joinCar" onclick="showBuyDiv(1,1);" type="button" class="skin-b1 am-btn am-btn-warning item2-panel-button" disabled="disabled">买</button>

                            <?php }else{?>

                                <button id = "joinCar" onclick="showBuyDiv(1);" type="button" class="skin-b1 am-btn am-btn-warning item2-panel-button" disabled="disabled">加入购物车</button>

                            <?php }?>

                        <?php }else if($sid > 0 && (0 == $is_admin_closed || 0== $is_owner_closed)){?>
                            <?php if($is_buy_sale_model == 1){ ?>

                                <button id = "button4" onclick="alert('商家不在营业时间内')" type="button" class="skin-b1 am-btn am-btn-warning item2-panel-button text-hidden" disabled="disabled">买</button>


                            <?php }else{?>
                                <button id = "button4" onclick="showlevel(<?php echo $is_allow_buy;?>);showBuyDiv(1,1);" type="button" class="skin-b1 am-btn am-btn-warning item2-panel-button text-hidden" disabled="disabled">加入购物车</button>
                            <?php }?>


                        <?php  }?>
                    <?php } ?>



                </div>
                <div class = "item2-panel">
                    <!-- <php if($sid < 0){ ?> -->

                    <?php if($sid<0){ ?>

                        <?php if($is_buy_sale_model == 1){ ?>

                            <?php if($is_promoters == 1){?>
                                <button id = "sellDiv" onclick="showsellDiv(2);" type="button" class="skin-b2 am-btn  am-btn-danger item2-panel-button" disabled="disabled">卖</button>
                            <?php }?>
                        <?php }else{?>
                            <button id = "buyDiv" onclick="showBuyDiv(2);" type="button" class="skin-b2 am-btn  am-btn-danger item2-panel-button" disabled="disabled">立即购买</button>
                        <?php }?>

                    <?php }else if($sid > 0 && 1 == $is_admin_closed && 1== $is_owner_closed){ ?>

                        <?php if($is_buy_sale_model == 1){ ?>
                            <?php if($is_promoters == 1){?>
                                <button id = "sellDiv" onclick="showsellDiv(2);" type="button" class="skin-b2 am-btn  am-btn-danger item2-panel-button" disabled="disabled">卖</button>
                            <?php }?>
                        <?php }else{?>
                            <button id = "buyDiv" onclick="showBuyDiv(2);" type="button" class="skin-b2 am-btn  am-btn-danger item2-panel-button" disabled="disabled">立即购买</button>
                        <?php }?>

                    <?php }else if($sid > 0 && (0 == $is_admin_closed || 0== $is_owner_closed)){?>

                        <?php if($is_buy_sale_model == 1){ ?>
                            <?php if($is_promoters == 1){?>
                                <button id = "sellDiv" onclick="showsellDiv(2);" type="button" class="skin-b2 am-btn  am-btn-danger item2-panel-button" disabled="disabled">卖</button>
                            <?php }?>
                        <?php }else{?>
                            <button id = "button3" onclick="alert('商家不在营业时间内')" type="button" class="skin-b2 am-btn  am-btn-danger item2-panel-button text-hidden" <?php if($issnapup){?>disabled="disabled"<?php }?>>商家休息中</button>
                        <?php }?>


                    <?php  }?>

                        <!--button id = "sellDiv" onclick="showsellDiv(3,16.01);" type="button" class="am-btn  am-btn-danger item2-panel-button">卖</button-->

                </div>
            </div>
            <?php }else{?>
            <div class="item2">
                <!-- <div class = "item2-panel">
                    <button id="" onclick="" style="width:170%;height:40px;background-color:#ccc;border:1px solid #ccc;color:#666;font-size:14.33px;"  type="button" class="skin-b2 am-btn am-btn-warning item2-panel-button">您没有权限购买此产品</button>
                </div> -->
                <div  style="display: block;margin-top:10px;text-align:center;">
                    <button id = "joinCar"  class=" disable1 am-btn  item2-panel-button" style="background-color: #D7D7D7;cursor: auto;color:#666;border: none;font-weight: 600; margin-left: -35px" disabled="disabled">您没有权限购买此产品</button>
                </div>
            </div>
            <?php }?>
        <?php }else{?>
            <div class = "item2" <?php if(!$isbrand_supply)echo 'style="padding-left: 95px;"';?>>
                <div class = "item2-panel">
                    <button id = "joinCar"  class=" disable1 am-btn  item2-panel-button" style="background-color: #D7D7D7;cursor: auto;color:#666;border: none;font-weight: 600;" disabled="disabled">立即购买</button>
                </div>
                <div class = "item2-panel" >
                    <button id = "joinCar"   class=" am-btn  item2-panel-button" style="background-color: #D7D7D7;cursor: auto;color:#666;border: none;font-weight: 600;" disabled="disabled" >加入购物车</button>
                </div>
            </div>
        <?php }?>


        </div>
        <?php } ?>

    <!-- footer content -->






	<!-- footer content1 -->
	<!--div class="shangpin-footer">
	    <div class="item1 collect_1" id="item1-cell1 collect_1" onclick="collect(3933,1,'add')" style="">
	    	<div class="shangpin-footer-item1-row1">
	    		<img src="./images/goods_image/2016042701.png">
	    	</div>
    		<div class="shangpin-footer-item1-row2">
    			<span>收藏</span>
    		</div>
    	</div>
		<div class="item1 collect_2" id="item1-cell1 collect_2" onclick="collect(3933,1,'del')" style="display:none;">
    		<div class="shangpin-footer-item1-row1">
    			<img src="./images/goods_image/collect.png">
    		</div>
    		<div class="shangpin-footer-item1-row2">
    			<span style="color:#ff8430">已收藏</span>
    		</div>
    	</div>
    	<div class="item1  button buttonclick">
			<a href="order_cart.php?customer_id=VWBba1U3UGo=">
				<div class="shangpin-footer-item1-row3">
					<img src="./images/goods_image/2016042703.png">
					 <span id="badge-span" style="display: none;">0</span>
				</div>
				<div class="shangpin-footer-item1-row2 pt1">
					<span>购物车</span>
				</div>
    		</a>
    	</div>
		<div class="item2" style="padding-left: 95px;">
    		<div class="item2-panel">
			    <button id="buyDiv" onclick="showBuyDiv3(3);" type="button" class="am-btn am-btn-warning item2-panel-button">买</button>
			</div>
			<div class="item2-panel">
				<button id="sellDiv" onclick="showsellDiv(3,16.01);" type="button" class="am-btn am-btn-danger item2-panel-button">卖</button>
    		</div>
    	</div>
	</div-->
	<!-- footer content1 -->





<div class="helper">
    <div class="forward"></div>
</div>

    <!-- dialog -->
    <div class="am-share shangpin-dialog" style="z-index:4999;">
    <div class="content-base  row1"><div class="dlg-row1-cell0"><img class="am-img-thumbnail am-circle" onclick="closeDialog();" src="./images/goods_image/2016042704.png" ></div></div>
        <!-- 加入购买 -->
	  	<div class = "content-base   dialog-content">
	  	<!-- <img  class="am-img-thumbnail am-circle close-img" src = "./images/goods_image/2016042704.png" > -->
	  		<div class = "content-base content-row1">
	  			<div class = "dlg-content-row1-left" id="Preview" value="0" >
	  				<img src = "<?php echo $default_imgurl; ?>">
	  			</div>
	  			<div class = "dlg-content-row1-right" >
	  				<div class = "dlg-content-row1-right-top1">
	  					<span><?php echo $p_name; ?></span>
	  				</div>
	  				<div class = "dlg-content-row1-right-top2">
	  					<span>
							<?php if(OOF_P != 2) echo OOF_S ?>
							<span id="now_price">
							<?php 
                				if($integral_type == 2 && $integral_result['errcode']==0 && $integral_result['data'][$pid]['integral_p']>0 ){  //积分兑换价格
                                    $integral_now_price = number_format($integral_result['data'][$pid]['money_p'],2);
                					echo number_format($integral_result['data'][$pid]['money_p'],2);
                				}else{
                					echo number_format($p_now_price,2);
                				}
                			?>
							</span>
							<?php if(OOF_P == 2) echo OOF_S ?>
						</span>
						<span class="sign_add" style="color:#000;">+</span>
						<span class = "need_score_span dlg-content-row1-right-top2-span">
							<span id="need_score">
							<?php echo $p_need_score; ?>
							</span>
							积分
						</span>
	  				</div>
	  			</div>
	  		</div>
	  		<div class="ov-class pros-box">
			<?php
			
			 $query="select id ,name from weixin_commonshop_pros where  parent_id=-1 and isvalid=true and customer_id=".$customer_id;
			 $result = _mysql_query($query) or die('Query failed11: ' . mysql_error());
			 while ($row = mysql_fetch_object($result)) {
				$prname = $row->name;
				$prid = $row->id;
				$ishasSet_t =false;
			?>
	  		<div id="pro_<?php echo $prid;?>" class = "pro_div <?php if($attr_parent_id == $prid ){ echo 'parent_attr_img';}?>" >
	  			<div class = "big_pro_name">
					<span><?php echo $prname;?>:&nbsp;&nbsp;</span>
				</div>
				<script>var subids = "";</script>
	  			<div pos_name="<?php echo $prname;?>" class = "small_pro_div">
					<?php
					$if_attr_img = 0;
					if($attr_parent_id == $prid ){ //判断是否父属性是该产品图片主属性
						$if_attr_img = 1;
					}
					$query2="select id,name from weixin_commonshop_pros where isvalid=true and parent_id=".$prid;
					$result2 = _mysql_query($query2) or die('Query failed12: ' . mysql_error());
					$i					= 1;
					$fir_subid			= -1;
					$pro_shownameLst 	= "";
					while ($row2 = mysql_fetch_object($result2)) {
						$subname	= $row2->name;
						$subid		= $row2->id;
						if( $i == 1 ){
							$fir_subid=$subid;
						}
						//初始化属性图片
						
						$attr_img_path= '';
						$temp_index   = 0;
						//是该产品图片主属性并且存在图片
						if( array_key_exists($subid,$attr_img_array) && $if_attr_img)
						{ 
							
							$attr_img_path= $attr_img_array[$subid]['img'];
							$temp_index   = $attr_img_array[$subid]['index'];
						} 
						if($proLst->Contains($subid) and !empty($subname)){
							$ishasSet	= true;
							$ishasSet_t = true;
							if(empty($pro_shownameLst)){
								$pro_shownameLst=$subid;
							}else{
								$pro_shownameLst=$pro_shownameLst."_".$subid;
							}
					?>
		  			<div pos_id="<?php echo $subid;?>" attr_index="<?php echo $temp_index;?>" class="pos_<?php echo $prid; ?> pos_div pt_pros_div" onclick="chooseDiv(<?php echo $prid; ?>,<?php echo $subid; ?>);" id = "pro_div_<?php echo $prid; ?>_<?php echo $subid; ?>" attr_img="<?php echo $attr_img_path;?>">
						<span class="span_pos_<?php echo $prid; ?>" ><?php echo $subname; ?></span>
					</div>
					<script>subids = subids+<?php echo $subid; ?>+
                                    "_";</script>
					<?php
						}
					}
					if(!$ishasSet_t){
						echo "<script>document.getElementById('pro_".$prid."').style.display='none';</script>";
					}else{

					?>
						<input type=hidden name="prvalues" id="invalue_<?php echo $prid; ?>" value="" />
					<?php } ?>
					<script>
                        if (subids != "") {
                            subids = subids.substring(0, subids.length - 1);
                        }
                        selproHash.add(<?php echo $prid; ?>, subids);
                    </script>
	  			</div>
	  		</div>
			<?php
				if ($ishasSet_t) {
					if (empty($showpname)) {
						$showpname = $showpname . $prname;
					} else {
						$showpname = $showpname . "," . $prname;
					}
					$proHash->insert($prname, $pro_shownameLst);
					//echo "snamelst=======".$prname."========".$pro_shownameLst;
				}
			}
			if ($default_pids != "") {
				$default_pids = rtrim($default_pids, "_");
			}
			?>

			<?php
				$id = -1;
				$is_wholesale = 0;
				$wholesale_parentid = "";
				$wholesale_childid = "";
				$query = "SELECT id,wholesale_parentid,wholesale_childid FROM weixin_commonshop_product_extend WHERE isvalid=true AND customer_id=$customer_id AND pid=$pid LIMIT 1";
				//echo $query;
				$result= _mysql_query($query) or die('Query failed 1309: ' . mysql_error());
				while( $row = mysql_fetch_object($result) ){
					$id 				= $row->id;
					$wholesale_parentid = $row->wholesale_parentid;
					$wholesale_childid 	= $row->wholesale_childid;
				}
				if($id > 0){
					$is_wholesale = 1;//判断是否拥有批发属性
					$parent_id = -1;
					$parent_name = "";
					$sql = "SELECT id,name FROM weixin_commonshop_pros WHERE isvalid=true AND id=$wholesale_parentid AND parent_id=-1 AND is_wholesale=1 LIMIT 1";
					$res = _mysql_query($sql) or die('Query failed 1320: ' . mysql_error());
					while( $info = mysql_fetch_object($res) ){
						$parent_id = $info->id;
						$parent_name = $info->name;
					}

			?>
			<div id="pro_<?php echo $parent_id;?>" class = "pro_div <?php if($attr_parent_id == $parent_id ){ echo 'parent_attr_img';}?>">
				<div class = "big_pro_name">
					<span><?php echo $parent_name;?>:&nbsp;&nbsp;</span>
				</div>
				<div pos_name="<?php echo $parent_name;?>" class="small_pro_div">
					<?php
						$if_attr_img = 0;
						if($attr_parent_id == $parent_id ){ //判断是否父属性是该产品图片主属性
							$if_attr_img = 1;
						}

						$wholesale_arr = array();
						$wholesale_arr = explode("_",$wholesale_childid);
						for($i=0;$i<count($wholesale_arr);$i++){

							$child_id = -1;
							$child_name = "";
							$wholesale_num = 1;
							$query_child = "SELECT id,name,wholesale_num FROM weixin_commonshop_pros WHERE isvalid=true AND parent_id=$parent_id AND id=$wholesale_arr[$i]";
							$result_child= _mysql_query($query_child) or die('Query failed 1335: ' . mysql_error());
							while( $info_child = mysql_fetch_object($result_child) ){

								$child_id = $info_child->id;
								$child_name = $info_child->name;
								$wholesale_num = $info_child->wholesale_num;

								//初始化属性图片
								$attr_img_path= '';
								$temp_index   = 0;
								//是该产品图片主属性并且存在图片
								
								if( array_key_exists($child_id,$attr_img_array) && $if_attr_img)
								{ 
									$attr_img_path= $attr_img_array[$child_id]['img'];
									$temp_index   = $attr_img_array[$child_id]['index'];
								} 

					?>
					<div pos_id="<?php echo $child_id;?>" class="pos_<?php echo $parent_id; ?> pos_div wholesale_div" onclick="chooseDiv(<?php echo $parent_id; ?>,<?php echo $child_id; ?>);" id = "pro_div_<?php echo $parent_id; ?>_<?php echo $child_id; ?>" pos_num="<?php echo $wholesale_num ;?>" attr_index="<?php echo $temp_index;?>" attr_img="<?php echo $attr_img_path;?>">
						<span class="span_pos_<?php echo $parent_id; ?>" ><?php echo $child_name;?></span>
					</div>

					<!-- <script>subids = subids+<?php echo $child_id; ?>+"_";</script> -->
					<input type=hidden name="prvalues" id="invalue_<?php echo $parent_id; ?>" value="" />
					<?php }}?>

				</div>
				<input type="hidden" name="wholesale_num" id="wholesale_num" value="1">
			</div>
			<?php }?>

			</div>
	  		<div id="numDiv" class = "content-base content-row4">
	  			<span class = "dlg-content-row4-span">数量:&nbsp;&nbsp;</span>
	  			<div class = "num_div">
	  				<div class = "minus button buttonclick" onclick="minusNum();" ><span>-</span></div>
	  				<div class = "count_div">
						<!-- <span id = "mount_count">3</span> -->
						<input onblur="modify();" type="text" value="1" id="mount_count" autocomplete="off" onkeyup="clearNoNum(this)" onafterpaste="clearNoNum(this)">
					</div>
	  				<div class = "add button buttonclick" onclick="addNum();"><span>+</span></div>
	  			</div>
				<div id="stock_div">
					库存:
					<span id="stock">
					<?php echo $p_storenum; ?>
					</span>
				</div>
	  		</div>
	  		<!-- 加入购买 -->

  			<div class = "div-clear"></div>


	  		<div class = "content-button" id= "div_joinCar">
	  		<?php if($is_virtual > 0 ){	//虚拟产品不能加入购物车?>
					<button id="another_joinCar"  onclick="showlevel(<?php echo $is_allow_buy;?>);addToCart();" type="button" class="am-btn am-btn-warning text-hidden" disabled="disabled">加入购物车</button>
				<?php } else {?>

		  			<button id="another_joinCar" type="button" onclick="addToCart();" class="am-btn am-btn-warning" disabled="disabled">加入购物车</button>

			<?php } ?>
	  		</div>
			<?php
				if( $is_collage_product == 1 ){
			?>
	  		<div class = "content-button" id = "div_buyNow" >
	  				<button id="collage_buyNow" type="button" onclick="buyGood();" class="am-btn am-btn-danger">立即购买</button>
	  		</div>
			<?php
				} else {
			?>
			<div class = "content-button" id = "div_buyNow" >
	  				<button id="another_buyNow" type="button" onclick="buyGood();" class="am-btn am-btn-danger" disabled="disabled">立即购买</button>
	  		</div>
			<?php
				}
			?>
	  	</div>
	  	<!-- dialog -->
	</div>

<!-- dialog1 -->

	<!-- dialog 1-->

	<div id="qrcode_div">
		<div id="close_qr" onclick="close_code();">
			<img src="images/info_image/btn_close.png" width="30">
		</div>
		<div id="code_img">
			<i class="wx_loading_icon"></i>
		</div>
		<div id="refresh_qr">
			<div class="refresh">
				<span>长按图片保存二维码</span>
				<img onclick="get_qrcode();" src="images/info_image/refresh.png" >
			</div>
		</div>
	</div>

	<div id="coupon_div" style="display: none;">
		<div id="close_coupon" onclick="close_coupon();" style="padding-right: 41px; display: block;">
		<img src="images/info_image/btn_close.png" width="30">
		</div>
		<div class="box_div">
			<div class="coupon_font">可领取优惠券</div>
		<div class="coupon_overflow">
			<?php
			$nowtime = date('Y/m/d',time());				//优惠劵开始时间
			foreach($coupon_array as $key =>$values){

					$coupon_id 		= $values->id;
					$coupon_title 	= $values->title;
					$NeedMoney 		= $values->NeedMoney;
					$MaxMoney 		= $values->MaxMoney;		//这里作为单品优惠劵的固定优惠金额
					$CanGetNum 		= $values->CanGetNum;
					$MoneyType 		= $values->MoneyType;
					$user_scene 	= $values->user_scene;
					$Days 			= $values->Days;
					$DaysType 		= $values->DaysType;		//截止时间类型 0:截止天数,1:截止日期
                    $class_type 	= $values->class_type;
                    $startline 		= $values->startline;		//使用开始时间
                    $connected_id   = $values->connected_id;	//单品代金卷就是关联产品ID；商铺代金卷就是关联供应商ID

                    $coupon_isvalid = true; 					//是否有效
					//当使用开始时间比现在时间要晚，则使用设置的开始时间
					if(strtotime($startline) > time()){
						$nowtime =  date('Y/m/d',strtotime($startline));
					}

					$endtime = '';							//优惠劵结束时间
					if($DaysType == 1){
						$endtime = $Days;
					}else{
						$endtime = date('Y/m/d',strtotime("+".$Days." day"));
					}

					if($user_scene==1 && !empty($connected_id) ){
						$cou_product_name = array();
						$cou_product_sql  = "select name from weixin_commonshop_products where id in (".$connected_id.") and isvalid = 1 ";
						$result_cou_product=_mysql_query($cou_product_sql);
						while ($row_cou = mysql_fetch_object($result_cou_product)) {
							$cou_product_name[] = $row_cou->name;
							
						}
						
						if(empty($cou_product_name)){ 		//查询该产品失败
							$coupon_isvalid = false;
						}
						$cou_product_name = implode(",",$cou_product_name);
						
						$remark = "仅限购买商品【".$cou_product_name."】使用";
					}elseif( empty($connected_id) ){
						$coupon_isvalid = false;
					}else{
						$remark = "仅限购买平台商品使用";
					}
                if( ($is_collage_from == 1 || ($is_collage_from == 0))&&$coupon_isvalid == true ){
			?>
			<div class="box">
				<div class="bottomdiv " style="background-color:<?php if($user_scene==0) echo '#ff675f';?>" onclick="get_coupon(<?php echo $coupon_id.",".$pid;?>)">
					<div class="tag_new tag orange  " style="background-color:<?php if($user_scene==0) echo '#F44A4A';?>;color:<?php if($user_scene==0) echo '#A81616';?>;"><?php if($user_scene==0){echo '平台';}else{echo '商品';} ?>专用券</div>
					<div class="leftdiv " style="background-color:<?php if($user_scene==0) echo '#ff675f';?>">
					<div class="topp">有效期:<span><?php echo $nowtime;?>--<?php echo $endtime; ?></span></div>
					<div class="botdiv">
						<div class="botleft"><span class="coupon_absolute">
						<!--  <?php if($MoneyType==1) echo '最高';?> 最高请在备注里写明，最多四位数例如99.00 -->

						<span class="five_font orangefive"><?php echo $MaxMoney; ?></span><?php echo OOF_T ?>

                        </span></div>
						<div class="botright">
							<div class="ptwo">备注：<span><?php echo $remark; ?></span></div>
						</div>
					</div>
					</div>
					<div class="rightdiv  " style="background-color:<?php if($user_scene==0) echo '#F44A4A';?>">
						<?php if($NeedMoney>=0){?>
							<div class="lineone">满
							<span class="cont" >
							<?php echo $NeedMoney;?>
							</span><?php echo OOF_T ?>
						<?php }else{ ?>
							<div class="lineone">不限金额</span>
						<?php } ?>
						</div>
						<div class="lineone">即可使用</div>
						<div class="linetwo">(不含邮费)</div>&gt;
						<div class="linethree red" style="color:<?php if($user_scene==0) echo '#ff675f';?>" >立即领取<span></span></div>
					</div>
				</div>
			</div>
		<?php
                }
        }?>
		</div>
		</div>
	</div>
	<div id="screen" onclick="close_coupon();"></div>
	<input type="hidden" id="supply_id" value="<?php echo $sid; ?>"/>
	<input type="hidden" id="pid" value="<?php echo $pid; ?>"/>
	<input type="hidden" id="topic_id" value="<?php echo $topic_id; ?>"/>
	<input type="hidden" id="resource_id" value="<?php echo $resource_id; ?>"/>
</body>
<!-- 页联系js -->
	<script type="text/javascript" src="./js/ImgPreview.js"></script>
	<script type="text/javascript" src="./js/swiper.min.js"></script>

    <script type="text/javascript" src="./assets/js/amazeui.js"></script>
    <script type="text/javascript" src="./js/global.js?ver=<?php echo JSVER?>"></script>
    <script type="text/javascript" src="./js/loading.js"></script>
    <!-- <script type="text/javascript" src="./js/data.js"></script> -->
    <script type="text/javascript" src="./js/region_select.js"></script>

    <script src="./js/goods/mobiscroll/mobiscroll.custom-2.17.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(".shangpin-second2").find('table').css("width","");
$(".shangpin-second2").find('table').attr("width","");
var count_commodity 	= '<?php echo $count_commodity?>'
var is_allow_buy 		= "<?php echo $is_allow_buy; ?>";
var from_type			= "<?php echo $from_type; ?>";
var pid					= "<?php echo $pid; ?>";
var customer_id			= '<?php echo $customer_id_en; ?>';
var customer_id2		= '<?php echo $customer_id; ?>';
var user_id				= '<?php echo $user_id; ?>';
var owner_id			= '<?php echo $owner_id; ?>';
var supply_id			= '<?php echo $sid; ?>';
var pro_act_type		= <?php echo $pro_act_type; ?>;		//产品活动类型，22积分兑换产品
var sid			        = '<?php echo $sid; ?>';

var need_integral 		= '<?php echo $integral_result['data'][$pid]['integral_p'];?>';		 //兑换产品需要的商城积分
var need_store_integral = '<?php echo $integral_result['data'][$pid]['store_integral_p'];?>';//兑换产品需要的门店积分
var user_integral 		= '<?php echo $user_integral;?>';		//用户商城积分
var user_store_integral = '<?php echo $user_store_integral;?>';	//用户门店积分
var shop_integral_onoff = '<?php echo $shop_integral_onoff;?>';		//商城积分开关
var store_integral_onoff= '<?php echo $store_integral_onoff;?>';	//门店积分开关

var vp_val = '<?php $vp_val;?>';
var isvp = '<?php $isvp;?>';
var vp_score = '<?php $vp_score;?>';

/* if(pro_act_type!=22){ */
    var buystart_time		= '<?php echo strtotime($buystart_time);?>';
    var buyend_time			= '<?php echo strtotime($countdown_time);?>';
    var buystart_time_format= '<?php echo date('Y/m/d',strtotime($buystart_time));?>';
    var buyend_time_format	= '<?php echo date('Y/m/d',strtotime($countdown_time));?>';
/* }else{
    var buystart_time		= '<?php echo strtotime($istart_time);?>';
    var buyend_time			= '<?php echo strtotime($iend_time);?>';
    var buystart_time_format= '<?php echo date('Y/m/d',strtotime($istart_time));?>';
    var buyend_time_format	= '<?php echo date('Y/m/d',strtotime($iend_time));?>';
} */
//console.log(pro_act_type)
var runtimes 			= 0;

var product_vedio		= '<?php echo $product_vedio;?>';
var product_voice		= '<?php echo $product_voice;?>';
var w_heigjt			= $(window).height();//屏幕高度
var w_width				= $(window).width();//屏幕宽度度
var default_pids 		= "<?php echo $default_pids; ?>";
//console.log(default_pids);
var p_now_price 		= "<?php echo $p_now_price; ?>";//现价
var integral_now_price  = "<?php echo $integral_now_price; ?>";//积分兑换产品现价
var for_price 			= "<?php echo $for_price; ?>";//成本价
var cost_price 			= "<?php echo $cost_price; ?>";//供货价
var p_need_score 		= "<?php echo $p_need_score; ?>";//需要的积分
var p_storenum 			= "<?php echo $p_storenum; ?>";//库存
var isout	 			= "<?php echo $isout; ?>";//是否下架
var issnapup 			= "<?php echo $issnapup; ?>";//抢购产品
var is_stockOut 		= <?php echo $is_stockOut; ?>;//库存不足下架开关
var pro_card_level_id  	= <?php echo $pro_card_level_id; ?>;	//购买产品需要会员卡的等级
var pro_card_level  	= <?php echo $pro_card_level; ?>;	//购买产品需要会员卡等级开关
var shop_card_id  		= <?php echo $shop_card_id; ?>;	//分销会员卡id
var pis_identity  		= <?php echo $pis_identity; ?>;	//产品是否需要身份证购买
var is_identity  		= <?php echo $is_identity; ?>;	//是否开启身份证验证
var is_QR  				= <?php echo $is_QR; ?>;	//是否 二维码产品 0:否 1:是
var is_virtual			= '<?php echo $is_virtual; ?>';	//是否为虚拟产品 0:非虚拟产品,1:虚拟产品
var is_showdiscuss		= '<?php echo $is_showdiscuss; ?>';
var isvalid				= '<?php echo $isvalid; ?>';
var is_promoters		= '<?php echo $is_promoters; ?>';	//是否是推广员
var Plevel				= '<?php echo $Plevel; ?>';	//推广员等级
var issell_model		= '<?php echo $issell_model; ?>';	//复购开关
var init_reward			= '<?php echo $init_reward; ?>';	//商城分佣比例
var pro_reward			= '<?php echo $pro_reward; ?>';	//产品分佣比例
var is_product_shuf 		= '<?php echo $is_product_shuf;?>';	//是否自动轮播 0否，1是
var is_show_original		= '<?php echo $is_show_original;?>';	//是否显示原价 0否，1是
var islimit				= '<?php echo $islimit;?>';	//是否限购 0否，1是
var limit_num			= '<?php echo $limit_num;?>';	//限购数量
//setPrice(default_pids);
var is_consume			= '<?php echo $is_consume; ?>';	//是否满足消费无限级奖励/股东分红 0:普通推广员 1:代理 2:渠道 3:总代理 4:股东
var tax_type			= "<?php echo $tax_type;?>";
var check_first_extend	= '<?php echo $check_first_extend;?>';//是否符合首次推广奖励
var is_collage_product	= <?php echo $is_collage_product;?>;	//拼团产品标识，1：是，0否
var singlePrice			= '<?php echo $singlePrice;?>';			//单独购买价格
var groupPrice			= '<?php echo $groupPrice;?>';			//团购价
var groupStock			= '<?php echo $groupStock;?>';			//团购库存
var groupBuyType		= 1;					//判断单独购买还是团购，1单独购买，2团购
var activitie_id		= '<?php echo $collage_product_info['activitie_id']?>';	//团活动id


if(pro_act_type!=22){
    var collage_start_time	= '<?php echo strtotime($collage_product_info['start_time']);?>';	//活动开始时间
    var collage_end_time	= '<?php echo strtotime($collage_product_info['end_time']);?>';		//活动结束时间
}else{
    var collage_start_time	= '<?php echo strtotime($istart_time);?>';
    var collage_end_time	= '<?php echo strtotime($iend_time);?>';
}

var is_stockOut_bak		= <?php echo $is_stockOut; ?>;		//库存不足下架开关
var pro_card_level_bak	= <?php echo $pro_card_level; ?>;	//购买产品需要会员卡等级开关
is_wholesale 			= "<?php echo $is_wholesale; ?>";//是否拥有批发属性
var g_app_type			= "<?php echo $g_app_type;?>";	//app类型
var is_aog				= <?php echo $is_aog;?>;		//是否预到货产品
var delivery_id			= <?php echo $delivery_id;?>;	//预配送时间设置id
var delivery_name		= '<?php echo $delivery_name;?>';	//预配送活动名
var is_buy_sale_model	= <?php echo $is_buy_sale_model;?>;	//是否是买卖模式，0：默认模式，1：买卖模式
var integral_type	= <?php echo $integral_type; ?>;		//是否积分兑换产品，1否，2是

var pro_act_id			= <?php echo $pro_act_id; ?>;		//活动id
var restricted_isout	= <?php echo $restricted_isout; ?>;			//新限购活动状态
var buy_times			= <?php echo $buy_times; ?>;				//用户已购买该产品次数
var buy_quantity		= <?php echo $buy_quantity; ?>;				//用户已购买该产品数量
var purchase_times		= <?php echo $purchase_times; ?>;			//新限购 限制产品购买次数
var quantity_purchased	= <?php echo $quantity_purchased; ?>;	//新限购 限制产品购买数量
var restricted_id	    = <?php echo $restricted_id; ?>;
var restricted_product_id = <?php echo $restricted_product_id; ?>;
var is_restricted 		= <?php echo $is_restricted; ?>;	//是否参与限购活动
var active_countdown	= <?php echo $active_countdown; ?>;	//开始时间倒数
var default_imgurl  	= "<?php echo $default_imgurl;  ?>";
var define_share_image  = "<?php echo $define_share_image;  ?>";//自定义分享图片
var attr_img_str 		= "{<?php echo $attr_img_str;  ?>}";	//主属性图片
var attr_parent_id 		= '<?php echo $attr_parent_id;?>';	//主属性父id
var p_pro_str           = '<?php echo $p_pro_str;?>';			//父属性ID顺序链
var choose_arr  		= new Array();							//选择的属性数组  key ->pid value->id
if(p_pro_str.indexOf('_') != -1 ){
	var p_pro_arr 		= p_pro_str.split("_"); 
}	



var o_shop_id = <?php echo $o_shop_id; ?>; //订货系统门店id
var o_branch_id = <?php echo $o_branch_id; ?>; //订货系统子门店id
/*if(o_shop_id > 0){
	localStorage.setItem("cart_user_"+user_id+"_shopid", o_shop_id);
}*/

// console.log(pro_act_type);


//console.log(is_wholesale);
debug					= false;
//appId					= '<?php //echo $signPackage["appId"];?>//';
//timestamp				= <?php //echo $signPackage["timestamp"];?>//;
//nonceStr				= '<?php //echo $signPackage["nonceStr"];?>//';
//signature				= '<?php //echo $signPackage["signature"];?>//';
share_url				= "<?php echo $linkurl; ?>"; //分享链接
title					= "<?php echo $p_name; ?>"; //标题
desc					= '<?php echo $introduce; ?>'; //分享内容
if ( desc.length >= 120 ) {
	desc = desc.substring(0, 115)+'...';
}
<?php
if(!empty($define_share_image)){
?>
imgUrl					= '<?php echo $new_baseurl.$define_share_image; ?>'; // 分享图标
<?php
}else if(!empty($default_imgurl)){
?>
imgUrl					= '<?php echo $new_baseurl.$default_imgurl; ?>';
<?php
}else{
?>
imgUrl					= '<?php echo $pp_imgurl; ?>'; // 分享图标
<?php
}
?>
share_type				= 4;//自定义类型
var eva_done=0; //评论是否加载完成
var dis_pagenum = 1;
var eva_lock=0;//评论是否上锁
var PL = 0;//评论类型
$(function(){
    $(".colorchange").eq(0).css("color","#F4212B");
    $(".colorchange").click(function(){//点击切换评论，重新加载。
		PL = $(this).attr("PL");
        $(this).css("color","#F4212B").siblings().css("color","#333333");
		$("#thelist").html("");
		dis_pagenum=1;
		eva_done=0;
		eva_lock = false;
		pullUpAction (PL,dis_pagenum);
    })

})


//日历
if ( delivery_id > 0 ) {
	var data = JSON.parse('<?php echo json_encode($delivery_datetime)?>');

	if (data.length > 0) {
		$('.delivery_id').show();
		//日历
		$('.shangpin-neardate ul li').on('click',function(){
			$(this).addClass('active').siblings().removeClass('active');
			$('#preDeliveryDate').val($(this).attr('date'));
			$('#preDeliveryTime').val('');
		});

		var eDate = data[data.length-1],maxDate,Arr_data=[],Arr_all = [],Arr_between = [];
		var today = new Date();
		var Start = today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate();
		//获取最后日期
		if(eDate.style == 0){
			maxDate = eDate.end;
		}else{
			maxDate = eDate.day;
		}
		//所有可选日期
		for(var i = 0;i<data.length;i++){
			if(data[i].style == 0){
				getAllDate(data[i].start,data[i].end,Arr_data);
			}else{
				var Tdata = data[i].day.split("-");
				data[i].day = Tdata[0]+'-'+Tdata[1]+'-'+parseInt(Tdata[2]);
				Arr_data.push(data[i].day);
			}
		}

		//开始与结束之间的日期
		// getAllDate(Start,maxDate,Arr_all);
		//不可选日期
		var tmp = Arr_data;
		var o = {};
		for (var i = 0; i < tmp.length; i ++) {
			(tmp[i] in o) ? o[tmp[i]] ++ : o[tmp[i]] = 1;
		};
		for (x in o){
			Arr_between.push(x);
		};
		//月份减一
		for(var k in Arr_between){
			var temp = Arr_between[k].split("-");
			Arr_between[k] = temp[0]+'-'+(temp[1]-1)+'-'+temp[2];
		};
		var max = maxDate.split("-");
		var min = data[0]['day'].split("-");
		var timelist = 1;//是否选择时间段
		var isAutoShowPros = 0;	//是否需要自动显示属性框
		$('.getmovetime').mobiscroll().calendar({
			minDate:new Date(min[0],min[1]-1,min[2]),
			maxDate:new Date(max[0],max[1]-1,max[2]),//最后日期
			theme: 'mobiscroll',
			lang: 'zh',
			display: 'bottom',
			mode: 'clickpick',
			dateFormat: 'mm-dd',
			endYear: (new Date()).getFullYear() + 1,
			startYear:new Date().getFullYear(),
			onShow: function(html,inst){
			  $('.dw-cal-anim .dw-cal-day').each(function(){
				var that = $(this),
					time = that.data('full');
				if($.inArray(time, Arr_between) == -1){
					that.attr('class','dw-cal-day dw-cal-day-inv');
					return true;
				}
			  })
			},
			onSelect: function (dateText, inst) {
				$('.shangpin-neardate ul li').removeClass('active');
				var startDate = inst.getDate();
				$('#preDeliveryDate').val(startDate.Format("yyyy-MM-dd"));
				$('#preDeliveryTime').val('');
				$('.showmovetime').html(startDate.Format("yyyy-MM-dd"));
				if(timelist == 1){//是否选择时间段
					addTimeList(startDate.Format("yyyy-MM-dd"));
				}
			}
		})

		function getDate(datestr){
		  var temp = datestr.split("-");
		  var date = new Date(temp[0],temp[1],temp[2]);
		  return date;
		}
		function getAllDate(start,end,arr){
			var startTime = getDate(start);
			var endTime = getDate(end);
			while((endTime.getTime()-startTime.getTime())>=0){
				var year = startTime.getFullYear();
				var month = startTime.getMonth();
				var day = startTime.getDate();
				arr.push(year+"-"+month+"-"+day);
				startTime.setDate(startTime.getDate()+1);
			}
		}

		function addTimeList(date){
			var deliveryTime = [];
			$('.showmovetime').html(date);
			//获取时间段
			$.ajax({
				url: 'get_delivery_time.php?customer_id='+customer_id,
				dataType: 'json',
				type: 'post',
				async: false,
				data: {
					delivery_date: date,
					delivery_id: delivery_id
				},
				success: function (res) {
					if ( res.status == 1 ) {
						deliveryTime = res.delivery_time;
					} else {
						$('#preDeliveryDate').val('');
						$('#preDeliveryTime').val('');
						$('.showmovetime').text('');
						$('.showmovelist').text('');
						$('.shangpin-neardate ul li').removeClass('active');
						alertAutoClose(res.msg);
					}
				},
				error: function (err) {

				}
			})
			if ( deliveryTime.length > 0 ) {
				var str = '<div class="Timelist-bg"></div><div class="Timelist">';
					str += '<div class="Time-title">请选择时间段</div>';
					str += '<div class="Time-content"><ul>';
					for ( var i in deliveryTime ) {
						str += '<li>'+deliveryTime[i]+'</li>';
					}
					str += '<ul></div>';
					str += '<div class="Time-button"><button class="Time-true">确定</button><button class="Time-false">取消</button></div>';
					str += '</div>';
				$('body').append(str);
				$('.Time-content ul li').eq(0).addClass('skin-color');
				var winheight = $('.Timelist').height();
				$('.Timelist').css('margin-top',-winheight/2);
				$('.Time-content li').on('click',function(){
					$(this).addClass('skin-color').siblings().removeClass('skin-color');
				});
				$('.Time-true').on('click',function(){
					var active = $('.Time-content li.skin-color').text();
					$('.showmovelist').html(active);
					$('#preDeliveryTime').val(active);
					$('.Timelist,.Timelist-bg').remove();
					if ( isAutoShowPros ) {
						if ( is_buy_sale_model ) {
							showBuyDiv(1, 1);
						} else {
							showBuyDiv(2, 0);
						}
						isAutoShowPros = 0;
					}
				});
				$('.Time-false').on('click',function(){
					$('.Timelist,.Timelist-bg').remove();
				});
				$('.Timelist-bg').on('click',function(){
					$('.Timelist,.Timelist-bg').remove();
				});
			}

		}
	} else {
		// delivery_id = -1;
		// $('.delivery_id').remove();
		var html_dedelivery = '';
            html_dedelivery += '<div  style="display: block;margin-top:10px;text-align:center;">';
            html_dedelivery +='<button id = "joinCar"  class=" disable1 am-btn  item2-panel-button" style="background-color:#D7D7D7;cursor: auto;color:#666;border: none;font-weight: 600; margin-left: -35px" disabled="disabled">该产品还没到预配送时间</button>';
            html_dedelivery +='</div>';
            $(".item2").html(html_dedelivery);
	}

}

/*属性图预览*/
var Preview_data = eval('(' + attr_img_str + ')');

$('#Preview').Preview({
	data:Preview_data,/*数据*/
	index: $('#Preview').attr('value')/*选择的属性key*/
});


if(is_product_shuf == 0 ){	//自动轮播
	$(".am-slider").attr("data-am-slider","{'slideshow':false}");	//取消自动轮播
}else{
	$(".am-slider").attr("data-am-slider","{'slideshowSpeed':'3000'}");	//图片轮播的时间为3秒
}
//自动计算优惠劵的最大高度60%
var clientHeight = document.documentElement.clientHeight;
$('.coupon_overflow').css('max-height',clientHeight*0.6);

$('.detBtn').click(function(){
	var $obj=$(this);
	var $src=$obj.attr("src");
	if($src.match("xiala_icon")){
		$(".detBottom").fadeOut(200);
		$src=$src.replace("xiala_icon","xiangshang_icon")
		$obj.attr("src",$src);
	}else{
		$(".detBottom").fadeIn(200);
		$src=$src.replace("xiangshang_icon","xiala_icon")
		$obj.attr("src",$src);
	}
})

//人气团倒计时
var $rest_time = $('.rest_time');
var remaining_time_id = new Array();
var currtime = new Date().getTime().toString().substring(0,10);
$rest_time.each(function(){
	var group_id = $(this).data('id');
	var end_time = $(this).data('end_time');
	remaining_time_id[group_id] = setInterval('group_rest_time("'+group_id+'",'+end_time+')',1000);
})

if( $rest_time.length > 0 ){
	setInterval(function(){
		$.ajax({type:"HEAD",url:'ajax_get_servertime.php',complete:function(x){ currtime = new Date(x.getResponseHeader("Date")).getTime().toString().substring(0,10);}})//获取服务器时间
	},1000);
}

function group_rest_time(group_id,end_time){
	if( currtime < end_time ){
		var resttime = end_time - currtime;
		var nMS = resttime*1000;
		var nD  = Math.floor(nMS/(1000*60*60*24));
		var nH  = Math.floor(nMS/(1000*60*60))%24;
		var nM  = Math.floor(nMS/(1000*60)) % 60;
		var nS  = Math.floor(nMS/1000) % 60;

		if( nH < 10 ) {
			nH = '0'+nH;
		}
		if( nM < 10 ) {
			nM = '0'+nM;
		}
		if( nS < 10 ) {
			nS = '0'+nS;
		}

		if( nD > 0 ){
			$('.rest_time_'+group_id).text(nD+'天'+nH+':'+nM+':'+nS);
		} else {
			$('.rest_time_'+group_id).text(nH+':'+nM+':'+nS);
		}
	} else {
		clearInterval('remaining_time_id['+group_id+']');
		$('.rest_time_'+group_id).text('已结束！');
	}
	if( currtime == 0 ){	//没有网络的情况下无法获取当前时间
		// clearInterval('remaining_time_id['+group_id+']');
		$('.rest_time_'+group_id).text("您的网络异常");
	}
}
//清除选择的属性
function removeActive(){
	var $active = $('.pos_div');
	$active.each(function(){
		if( $(this).hasClass('active') ){
			$(this).click();
		}
	});
}

//js控制disable，如果为0：则显示，如果为1：则隐藏
var issnapup = <?php echo $issnapup; ?>;
//console.log(issnapup);
if(issnapup==0){
	$('#buyDiv').removeAttr("disabled");
	$('#sellDiv').removeAttr("disabled");
	$('#joinCar').removeAttr("disabled");
	$('#button4').removeAttr("disabled");
	$('#singleBuy').removeAttr("disabled");
	$('#another_joinCar').removeAttr("disabled");
	$('#another_buyNow').removeAttr("disabled");
    $(".disable1").attr('disabled',true);
}

function refresh2(op){
	$("#qr").html('<i class="wx_loading_icon"></i>');
	var customer_id 		= "<?php echo $customer_id;?>";
	var user_id 			= "<?php echo $user_id;?>";
	result_type = true;
	$.ajax({
        type: "post",
        url: "../common_shop/common/tc_erweima/tc_erweima.php",
		dataType:'json',
		// async:false,
        data: {
			customer_id:customer_id,
			user_id:user_id,
			/*shop_name:shop_name,
			exp_map_url:exp_map_url,
			own_status:own_status,
			weixin_name:weixin_name,
			weixin_headimgurl:weixin_headimgurl,
			fromuser:fromuser,
			promoter_id:promoter_id,
			commision_level:commision_level,
			isAgent:isAgent,
			is_consume:is_consume,*/
			op:op

		},
        success: function (result) {
			switch(result.type){
				case 1:
					$(".am-modal-dialog").html('<img src="'+result.exp_map_url+'">');
					var mh=$(window).height()*0.85;
	 					$('.am-modal-dialog').find('img').css('maxHeight',mh);
					$('.wx_loading_icon').hide();
				break;
				case 0:
					showAlertMsg("提示",result.remark,"确定");
				break;
				default:
				break;
			}
        }
	});
}

function refresh(op){
    if(op == "reflesh"){
		$("#qr").html('');
		$("#qr").html('<i class="wx_loading_icon"></i>');
		console.log($("#qr").html())
	}
	var customer_id 		= "<?php echo $customer_id;?>";
	var user_id 			= "<?php echo $user_id;?>";
	result_type = true;
	$.ajax({
        type: "post",
        url: "/weixinpl/common_shop/common/tc_erweima/tc_erweima2.php",
		dataType:'json',
		async:false,
        data: {
			customer_id:customer_id,
			user_id:user_id,
			/*shop_name:shop_name,
			exp_map_url:exp_map_url,
			own_status:own_status,
			weixin_name:weixin_name,
			weixin_headimgurl:weixin_headimgurl,
			fromuser:fromuser,
			promoter_id:promoter_id,
			commision_level:commision_level,
			isAgent:isAgent,
			is_consume:is_consume,*/
			op:op

		},
        success: function (result) {
			switch(result.type){
				case 1:
					if(result.exp_map_url){
						$(".am-modal-dialog").html('<img src="'+result.exp_map_url+'">');
					}
					var mh=$(window).height()*0.85;
	 					$('.am-modal-dialog').find('img').css('maxHeight',mh);
					$('.wx_loading_icon').hide();
					result_type = true;
				break;
				case 0:
					showAlertMsg("提示",result.remark,"确定");
					result_type = false;
				break;
				default:
					result_type = false;
				break;
			}
        }

	});
	return result_type;
}
function changeAddress(){
	$('#WSY_provinces').val(aog_p);
	$('#WSY_provinces').change();
	$('#WSY_city').val(aog_c);
	$('#WSY_city').change();
	$('#WSY_area').val(aog_a);
	$('#WSY_area').change();
	$('#WSY_Street').val(aog_d);
	$('.changeAddress,.Address-box').show();
}
function offAddress(){
	$('.changeAddress,.Address-box').hide();
}
function up_Address(){
	aog_p = $('#WSY_provinces').val();
	aog_c = $('#WSY_city').val();
	aog_a = $('#WSY_area').val();
	aog_d = $('#WSY_Street').val();

	if ( aog_p == '' ) {
		alertAutoClose('请选择省份！');
		return;
	}

	aog_p = aog_p?aog_p:'';
	aog_c = aog_c?aog_c:'';
	aog_a = aog_a?aog_a:'';
	aog_d = aog_d?aog_d:'';

	$('.aog_address').text(aog_p+aog_c+aog_a+aog_d);

	check_aog();

	offAddress();
}
function ctrl_address(add_data,provinces_id,city_id,area_id,default_p,default_c,default_a){
    console.log(add_data.length);
	var num=add_data.length;//获取数组长度
	var $provinces=$("#"+provinces_id);
	var $city=$("#"+city_id);
	var $area=$("#"+area_id);
	(function(){ //此匿名函数用于获取所有省份
		var provinces_opt='';
		for(var i=0;i<num;i++){
			if(add_data[i].LevelType==1){ //LevelType==1代表省
			provinces_opt='<option value='+add_data[i].name+'>'+add_data[i].name+'</option>'+provinces_opt;
			}
		}
		$provinces.append(provinces_opt);
	})();
	$provinces.val(default_p).attr("selected",true);//初始化省选项框
	get_city(default_p);//根据省获取城市列表
	$city.val(default_c).attr("selected",true);//初始化市选项框
	get_area(default_c);//根据市获取县城列表
	$area.val(default_a).attr("selected",true);//初始化县选项框
	//监听省改变，则下属城市改变
	$provinces.change(function(){
		$city.html('<select id='+city_id+'><option>市</option></select>');//初始化下属选项框
		$area.html('<select id='+area_id+'><option>县</option></select>');//同上
		var provinces_index=this.selectedIndex;
		var provinces_text=$(this).find("option").eq(provinces_index).text();//获取选中省名称
		console.log(provinces_text);
		get_city(provinces_text);
	})
	//监听市改变，则下属县城改变
	$city.change(function(){
		$area.html('<select id='+area_id+'><option>县</option></select>');
		var city_index=this.selectedIndex;
		var area_text=$(this).find("option").eq(city_index).text();		//获取选中市名称
			console.log(area_text);
		get_area(area_text);
	})
	function get_city(provinces_name){//此方法：根据省名称获取下属城市
		var city_opt='';
		for(var i=0;i<num;i++){
			if(add_data[i].LevelType==2&&add_data[i].MergerName.match(provinces_name)){//LevelType==2代表市
				city_opt='<option value='+add_data[i].name+'>'+add_data[i].name+'</option>'+city_opt;
			}
		}
		$city.append(city_opt);
	}
	function get_area(city_name){//此方法：根据市名称获取下属县城
		var area_opt='';
		for(var i=0;i<num;i++){
			if(add_data[i].LevelType==3&&add_data[i].MergerName.match(city_name)){//LevelType==3代表县
				area_opt='<option value='+add_data[i].name+'>'+add_data[i].name+'</option>'+area_opt;
			}
		}
		$area.append(area_opt);
	}
}

$(function(){
	var sp=$('.shangpin-dialog');
	var img=sp.find('.dlg-content-row1-left img');
	if(img.width()<img.height()){
		img.parent('.dlg-content-row1-left').addClass('type2');
	}
})

	/*3d素材*/
    $(function(){
    	var is_show_tag_threed="<?php echo $is_show_tag_threed; ?>"
		/*var arr=[];*/
		var het=0;
		var str=$('.shangpin-content-second');
		for(var i=0;i<$('.shangpin-content-second').children().length;i++){
			if($('.shangpin-content-second').children()[i].tagName=='IFRAME'){
				console.log(het)
//				if(is_show_tag_threed==1) {
//					str.prepend("<img src='3d_logo.png' name='lqw' style='width: 50px;height: 50px;position: absolute;top:'+het+'px;left: 0;'/>")
//				}
				/*arr.push(het)*/
				het=het+207;
			}else{
				var het1=$(".shangpin-content-second").children().eq(i).height()
				het=het+het1;
				console.log(het)
			}
		}
		//($('.shangpin-content-second').children()[i].tagName=='IFRAME').prepend("<img src='3d_logo.png' style='width: 50px;height: 50px;position: absolute;top:'+het+'px;left: 0;'/>");
        if(is_show_tag_threed=='0'){
        	$(".threed_show").hide();
    	}
    })
$(".shangpin-content").find("img").click(function (e) {
    e.preventDefault();
})
</script>
<script src="js/goods/global.js?ver=<?php echo JSVER?>"></script>
<script src="js/goods/product_detail.js?ver=<?php echo JSVER?>"></script>
<script src="js/vue.js?ver=<?= JSVER ?>"></script>
<!-- <script src="js/goods/product_detail_new.js?ver=<?php echo time(); ?>"></script> -->
<script src="js/goods/limitbuy.js"></script><!--限购方法ww-->
<script src="js/CheckUserLogin.js?ver=<?= JSVER ?>"></script><!--检验用户是否已登录-->
<?php require('../common/share.php'); ?>
</body>

<!-- <script src="js/mshop_share.js"></script> -->
</html>